-
-
-
+Vue.component('profil-card', {
+ template: `
+
+
-
exit_to_app
+
+
+ exit_to_app
+ Logout
+
-
-
Benutzername:
- {{ profil.user }}
- Studiengang:
- {{ profil.major }}
- Semester:
- {{ profil.semester }}
-
+
+ {{ auth.name }}
+ {{ auth.type }}
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
+
+
+ `,
-
- props: ['profil'],
-
+
+
+
+
+
+
`,
data: function () {
return {
- isCardModalActive: false
+ auth: auth,
+ abo: 7,
+ saved: 3,
+ isCardModalActive: false,
+ majorList: {
+ },
};
},
- methods: {
- close: function () {
+ computed: {
+ },
+ methods: {
+ logout: function() {
+ clearAuthState();
+ $.ajax({ url: "api/logout", method: "POST" });
+ router.push('/profil');
}
}
});
diff --git a/public/search.js b/public/search.js
new file mode 100644
index 0000000..fd6533d
--- /dev/null
+++ b/public/search.js
@@ -0,0 +1,144 @@
+var isSearchActive = false,
+ tagArray = ["lorem"];
+
+const dat=[
+ 'th',
+ 'efi',
+ 'wichtig',
+ ],
+ search_data = [];
+
+Vue.component('search',{
+ template: `
+
`,
+ data: function() {
+ return{
+ searchtext: "",
+ selected: [],
+ taglist: dat,
+ };
+ },
+ computed:{
+ filteredDataArray() {
+ return this.taglist.filter((option) => {
+ return option
+ .toString()
+ .toLowerCase()
+ .indexOf(this.searchtext.toLowerCase()) >= 0
+ })
+ }
+ },
+ methods: {
+ getFilteredTags(text) {
+ this.taglist = dat.filter((option) => {
+ return option
+ .toString()
+ .toLowerCase()
+ .indexOf(text.toLowerCase()) >= 0
+ })
+ this.search();
+ },
+ search: function() {
+ searching(this.searchtext);
+ },
+ saveTagsToArray: function() {
+ tagArray = this.selected;
+// console.info(tagArray);
+ },
+ list_messages: function() {
+ messages();
+ },
+ list_tags: function () {
+ $.ajax({url: "api/tag/ids", method: "GET"})
+ .done(jd => {
+ // NICHT SO wg. Vue: _messagelist = jd;
+ _taglist.splice(0, _taglist.length);
+ _taglist.push.apply(_taglist, jd);
+ // console.log("tag: jd: " + jd);
+ for (var e in jd) {
+ if (!_tags[jd[e]]) {
+ get_insert_tag(jd[e]);
+ }
+ }
+ }).fail(function (e, f, g) {
+ console.log("err: " + e + f + g);
+ });
+ },
+ clear: function() {
+ console.log("clear");
+
+ isSearchActiv = false;
+ this.searchtext = "";
+ this.list_messages();
+ },
+ },
+ mounted: function() {
+ //this.search();
+ this.list_tags();
+ },
+});
+
+// Global Functions !!!
+function get_insert_tag(id) {
+ $.ajax({
+ url: "api/tag/" + id,
+ method: "GET"
+ }).done(function(tag) {
+ dat.push("#" + tag.name);
+ }).fail(function(e, f, g) {
+ console.log("cannot load " + id + ".json: " + e + f + g);
+ })
+}
+
+function searching(searchtext) {
+ isSearchActiv = true;
+ console.log("Searchtext: " + searchtext.replace(/#/g, ''));
+ $.ajax({
+ url: "api/msg/search/" + searchtext.replace(/#/g, ''),
+ method: "GET"
+ }).done(jd => {
+ // NICHT SO wg. Vue: _messagelist = jd;
+ _messagelist.splice(0, _messagelist.length);
+ _messagelist.push.apply(_messagelist, jd);
+ //console.log("jd: "+jd);
+ for (var e in jd) {
+ if (!_messages[jd[e]]) {
+ get_insert_message(jd[e]);
+ }
+ }
+ }).fail(function(e, f, g) {
+ console.log("searching: err: " + e + f + g);
+ })
+}
+
+function messages() {
+ $.ajax({
+ url: "api/msg/ids",
+ method: "GET"
+ })
+ .done(jd => {
+ // NICHT SO wg. Vue: _messagelist = jd;
+ _messagelist.splice(0, _messagelist.length);
+ _messagelist.push.apply(_messagelist, jd);
+ //console.log("jd: "+jd);
+ for (var e in jd) {
+ if (!_messages[jd[e]]) {
+ get_insert_message(jd[e]);
+ }
+ }
+ }).fail(function(e, f, g) {
+ console.log("list_msg: err: " + e + f + g);
+ });
+}
diff --git a/server.js b/server.js
index d5ac4f7..aa9fd1c 100644
--- a/server.js
+++ b/server.js
@@ -6,12 +6,11 @@
* Requires express >= 4
*/
var common = require('./server/common'),
+ //admin = require ('./server/admin'),
authorize = require('./server/authorization'),
dbs = require('./server/dbs');
-/*
- dbs = require ('./server/dbs'),
- files = require ('./server/files');
-*/
+ //files = require ('./server/files');
+
const fs = common.fs, // file sync, read certificates
http = common.http, // http handler
https = require('https'), // https handler
@@ -19,7 +18,7 @@ const fs = common.fs, // file sync, read certificates
session = require('express-session'), // session management (security)
morgan = require('morgan'), // logger
mong = common.mongoose, // mongoose
-// serveFavicon = require('serve-favicon'), // provide favicon
+ serveFavicon = require('serve-favicon'), // provide favicon
bodyParser = require('body-parser'), // post request bodyparser
MongoStore = require('connect-mongo')(session); // use mongodb as session storage
@@ -29,8 +28,9 @@ var app = express();
* Init
*/
common .init();
+dbs .init (common);
authorize .init(common);
-dbs .init (common);
+//admin .init (common);
//files .init (common);
mong.Promise = global.Promise;
@@ -67,8 +67,8 @@ app.use(session({
//store: new MemoryStore ({checkPeriod: 24*3600*1000}), // memorystore
}));
-// TODO Favicon for Desktop
-//app.use (serveFavicon (__dirname + '/public/favicon.ico'));
+// Favicon for Desktop
+app.use (serveFavicon(__dirname + '/public/img/favicon.ico'));
// Minimal Logging
//app.use (morgan ('dev'));
@@ -112,7 +112,7 @@ app.use('/api', api_routes);
app.use(express.static(__dirname + '/public'));
// Other stuff is NOT authorized unless logged in
-//app.use (authorize.genCheckAuthorized ('user'));
+app.use (authorize.genCheckAuthorized ('user'));
// No error so far? Then it's a 404!
app.use(function (req, res, next) {
@@ -125,19 +125,20 @@ app.use(function (req, res, next) {
*/
// API allowed for all
api_routes.post('/login', authorize.login);
+api_routes.post('/logout', authorize.logout);
// Validate all other API calls
+// TODO - Validate API calls
//api_routes.use(authorize.genCheckAuthorized('user'));
-api_routes.post('/logout', authorize.logout);
// Add API routes
function addRoutes(r) {
for (var e in r.routes) {
var route = '/' + e + (r.routes[e].params ? "/" + r.routes[e].params : "");
var log = "Adding routes for " + route + ":";
- /*
- var auth = r.routes[e].auth || r.auth;
- if (auth) {
+
+ var isAuth = r.routes[e].auth || r.auth;
+ if (isAuth) {
log += " [auth]";
api_routes.use (route, function (req, res, next) {
if (! auth(req))
@@ -145,14 +146,13 @@ function addRoutes(r) {
next ();
});
}
- */
- /*
+
var role = r.routes[e].role || r.role;
if (role) {
log += " [role:"+role+"]";
api_routes.use (route, authorize.genCheckAuthorized (role));
}
- */
+
const methods = ["get", "post", "put", "delete"];
for (var m in methods) {
if (r.routes[e][methods[m]]) {
@@ -165,12 +165,15 @@ function addRoutes(r) {
}
addRoutes(dbs);
+//addRoutes (admin);
+//addRoutes (files);
/*
* Servers
*/
http.createServer(app).listen(common.config.httpPort, function () {
- console.log("Express http server listening on port " + common.config.httpPort);
+ console.log("Express http server listening on port " +
+ common.config.httpPort);
});
/*
@@ -184,6 +187,8 @@ http.createServer(app).listen(common.config.httpPort, function () {
* openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
* rm certrequest.csr
*/
+// >>>>>>>>>>>>>>>>>>>>>>>>>>> SSL: DISABLED <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+/*
if (common.config.httpsPort) {
var options;
try {
@@ -211,6 +216,8 @@ if (common.config.httpsPort) {
console.log("Note: https server disabled by config");
}
+ common.mongoose.set('useCreateIndex', true);*/
+
/*
* Uncaught Exceptions
*/
diff --git a/server/authorization.js b/server/authorization.js
index 7717ccb..800a5d9 100644
--- a/server/authorization.js
+++ b/server/authorization.js
@@ -3,13 +3,14 @@
/*
* Authorization
*/
-var common, User;
+var common, Users;
const ldap = require ('./ldap_ohm'),
- crypto = require ("../server/crypto");
+ crypto = require ('./crypto'),
+ dbs = require ('./dbs');
// deactivated is not used yet
-const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, deactivated: true, host: true };
-const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true };
+const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true, deactivated: true, host: true };
+const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true };
// Fill in session object
@@ -67,9 +68,9 @@ const authorization = {
return returnError();
return returnSession ();
}
-/*
+
// check local database, then ldap
- User.findById (req.body.user) .exec (function (err, entry) {
+ Users.findById (req.body.user) .exec (function (err, entry) {
// If there is a local user AND it has a password associated, test against this, and only this
if (entry != null && entry.pwd) {
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
@@ -80,7 +81,7 @@ const authorization = {
// check ldap
ldap.authorize (user.toLowerCase(), pwd, function (found) {
- console.log ("ldap authorize " + user + " returns " + JSON.stringify (found));
+ //console.log ("ldap authorize " + user + " returns " + JSON.stringify (found));
// No ldap entry either -> unauthorized
if (found == null) {
return returnError ();
@@ -100,7 +101,7 @@ const authorization = {
// Otherwise create standard user entry
return fillSession (req, found, {user:true}, returnSession);
});
- });*/
+ });
},
logout: function (req, res, next) {
fillSession (req, undefined, undefined, function (err) {
@@ -110,9 +111,8 @@ const authorization = {
init: function (_common) {
common = _common;
ldap.init (_common);
- //User = require('../database/user.model.js');;
+ Users = dbs.models.Users;
},
};
-
module.exports = authorization;
diff --git a/server/dbs.js b/server/dbs.js
index 069fc19..6c86cd3 100644
--- a/server/dbs.js
+++ b/server/dbs.js
@@ -169,6 +169,8 @@ const dbs = {
console.log('Database connection error.');
process.exit();
});
+ // Default 'collection.ensureIndex' is deprecated; New is '.createIndexes'
+ common.mongoose.set('useCreateIndex', true);
/* DB Schemata
* Privat fields: