+
Neue Nachricht erstellen
@@ -78,6 +78,8 @@ const CreateMsgRouter = {
data: function () {
return {
+ auth: auth,
+ isDisabled: false,
selected: [],
taglist: data,
};
@@ -91,7 +93,7 @@ const CreateMsgRouter = {
var _subject = $("#subject").val();
var _message = $("#message").val();
var _tag = tagArray;
- var _user = $("#user").val();
+ var _user = auth.name ? auth.name : $("#user").val();
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
$.ajax({
url: "api/msg",
@@ -140,6 +142,18 @@ const CreateMsgRouter = {
}
},
mounted: function () {
+ var userField = $('#user');
+ if (auth != null && auth.mail != '') {
+// userField.prop('placeholder',auth.name);
+ var authorName = auth.name.split(' ');
+ authorName = authorName[1] + ', ' + authorName[0];
+ userField.val(authorName);
+ userField.prop('disabled',true);
+ } else {
+ userField.prop('placeholder','User');
+ userField.prop('disabled',false);
+ }
+
this.list_tags();
if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign();
@@ -147,7 +161,7 @@ const CreateMsgRouter = {
};
function get_insert_tag(id){
- $.ajax({ url: "api/tag/"+id, method: "GET" }).done(function (tag) {
+ $.ajax({ url: "api/tag/id/"+id, method: "GET" }).done(function (tag) {
data.push("#" + tag.name);
console.log("Array:"+this.data);
}).fail(function (e, f, g) {
diff --git a/public/search.js b/public/search.js
index fd6533d..dd86a98 100644
--- a/public/search.js
+++ b/public/search.js
@@ -93,7 +93,7 @@ Vue.component('search',{
// Global Functions !!!
function get_insert_tag(id) {
$.ajax({
- url: "api/tag/" + id,
+ url: "api/tag/id/" + id,
method: "GET"
}).done(function(tag) {
dat.push("#" + tag.name);
diff --git a/server.js b/server.js
index aa9fd1c..305ce44 100644
--- a/server.js
+++ b/server.js
@@ -62,7 +62,7 @@ app.use(session({
name: 'om.sid',
store: new MongoStore({
mongooseConnection: mong.connection,
- ttl: 30 * 24 * 3600
+ ttl: 30 * 24 * 3600,
}), // mongoose + connect-mongo
//store: new MemoryStore ({checkPeriod: 24*3600*1000}), // memorystore
}));
diff --git a/server/authorization.js b/server/authorization.js
index 800a5d9..2bfe759 100644
--- a/server/authorization.js
+++ b/server/authorization.js
@@ -60,7 +60,6 @@ const authorization = {
});
}
- // TODO Auth: validate session ID
// Check whether to just validate current session ID
if (user === '' && pwd === '') {
console.log ("auth revalidate: " + req.session.user);
diff --git a/server/dbs.js b/server/dbs.js
index 6b7ff76..0362fbd 100644
--- a/server/dbs.js
+++ b/server/dbs.js
@@ -131,14 +131,15 @@ const dbs = {
});
},
},
- "tag": {
+ "tag/id": {
params: ":id",
- /* GET /api/tag/[tag-id]
+ /* GET /api/tag/id/[tag-id]
* -> Tag schema
* Get a particular tag
*/
get: function(req, res) {
- model.Tags.findById(req.params.id) .exec(function(err, result) {
+ model.Tags.findById(req.params.id)
+ .exec(function(err, result) {
if (err) {
console.log (err);
res.status(404).json(err);
@@ -149,6 +150,85 @@ const dbs = {
});
},
},
+ "usr/id": {
+ params: ":id",
+ /* GET /api/usr/[usr-id]
+ * -> User Schema
+ * Get a particular user
+ */
+ get: function(req, res) {
+ model.Users.findById(req.params.id)
+ .exec(function(err, result) {
+ if (err) {
+ console.log(err);
+ res.status(404).json(err);
+ } else {
+ //console.log(JSON.stringify(result));
+ res.json(result);
+ }
+ });
+ },
+ },
+ "usr": {
+ /* POST /api/usr
+ * <- User schema
+ * -> User schema
+ * Create a new user
+ */
+ post: function(req, res) {
+ model.User.create({
+ _id: req.body.id,
+ name: req.body.name,
+ type: req.body.type,
+ roles: req.body.roles,
+ hash: req.body.hash,
+ salt: req.body.salt,
+ pwd: req.body.pwd,
+ abos: req.body.abos,
+ bookmarks: req.body.bookmarks,
+ }, function(err, result) {
+ if (err) {
+ console.log (err);
+ return res.status(401).json(err.message);
+ } else {
+ res.json({message: "User created!!"});
+ }
+ if (result == null) {
+ return res.status(500).json("Can not create user.")
+ }
+ });
+ },
+ /* PUT /api/usr
+ * <- User schema
+ * -> User schema
+ * Change a user
+ */
+ put: function(req, res) {
+ model.Users.findById(reg.body._id)
+ .exec(function(err, entry) {
+ if (err)
+ console.log (err);
+ if (entry == null)
+ return res.status(404).json(err.message);
+ // TODO Catch edge cases
+ entry.save(function(err, data) {
+ // TODO Save/Update user
+ /*
+ _id: req.body.id,
+ name: req.body.name,
+ type: req.body.type,
+ roles: req.body.roles,
+ hash: req.body.hash,
+ salt: req.body.salt,
+ pwd: req.body.pwd,
+ abos: req.body.abos,
+ bookmarks: req.body.bookmarks,
+ */
+ res.json(data);
+ });
+ });
+ },
+ },
},
/* Initialize requirements
* - DB connection
@@ -210,7 +290,7 @@ const dbs = {
type: { type: String },
roles: { type: [String], required: true,
_comment: "" },
- tags: { type: [String],
+ abos: { type: [String],
_comment: "" },
//deactivated: { type: Boolean },
//host: { type: Boolean },
diff --git a/server/ldap_ohm.js b/server/ldap_ohm.js
index 5ae2f06..ced4a34 100644
--- a/server/ldap_ohm.js
+++ b/server/ldap_ohm.js
@@ -7,7 +7,7 @@ const ldap = require('ldapjs');
const ldap_escape = require('ldap-escape');
-// TODO: Where do I get the URL from?? A: Is given.
+// NOTE: Where do I get the URL from?? A: Is given.
var ldap_client = ldap.createClient({
//url: 'ldap://gso2.ads1.fh-nuernberg.de/',
url: 'ldap://sso.cs.ohm-hochschule.de:389/',
@@ -16,7 +16,7 @@ var ldap_client = ldap.createClient({
// timeouts don't work reliably
});
-// TODO: Where do I get the 'bindpath' parameters info from? A: Is given.
+// NOTE: Where do I get the 'bindpath' parameters info from? A: Is given.
const ldap_config = {
bindpath: 'cn=Users,dc=ohm-hochschule,dc=de',
timeout: 2000
@@ -89,14 +89,17 @@ const ldap_ohm = {
console.log("ldap search error after bind for user " + user);
return cb (null);
}
+ // ldap_test output
+// return_object = entry.object;
return cb (return_object);
});
res.on('error', function(err) {
console.log('ldap error: ' + err.message);
});
res.on('end', function(result) {
- // TODO: Did we forget something?
// TODO: analyze result.status?
+// console.info('ldap result: ');
+// console.info(result);
});
});
});