summaryrefslogtreecommitdiffstats
path: root/admportal/server/router/routes/csp.js
diff options
context:
space:
mode:
authorTimoney, Daniel (dt5972) <dtimoney@att.com>2017-02-15 10:37:53 -0500
committerTimoney, Daniel (dt5972) <dtimoney@att.com>2017-02-15 10:40:37 -0500
commit324ee36fe31763e507b422ab0a88e4230045e205 (patch)
treed0b04520f6657601c918ce63fd27575977624187 /admportal/server/router/routes/csp.js
parentf0c97e8db427481e28c0a16b789bc73801b35e47 (diff)
Initial commit for OpenECOMP SDN-C OA&M
Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680 Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com> Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
Diffstat (limited to 'admportal/server/router/routes/csp.js')
-rw-r--r--admportal/server/router/routes/csp.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/admportal/server/router/routes/csp.js b/admportal/server/router/routes/csp.js
new file mode 100644
index 00000000..435aaf91
--- /dev/null
+++ b/admportal/server/router/routes/csp.js
@@ -0,0 +1,84 @@
+var exec = require('child_process').exec;
+var dbRoutes = require('./dbRoutes');
+var fs = require('fs.extra');
+var properties = require(process.env.SDNC_CONFIG_DIR + '/admportal.json');
+
+var retURL = "";
+var noCookieUrl = "";
+var logoutUrl = "";
+
+function logout(req,res){
+ console.log("logout");
+ req.session.loggedInAdmin = undefined;
+ res.redirect('/login');
+}
+
+function login (req,res) {
+
+ var loggedInAdmin={};
+ var email = req.body.email;
+ dbRoutes.findAdminUser(email,res,function(adminUser){
+ if(adminUser !== null){
+
+ // make sure correct password is provided
+ if (req.body.password != adminUser.password) {
+ res.render("pages/login",
+ {
+ result:
+ {
+ code:'error',
+ msg:'Invalid password entered.'
+ },
+ header:process.env.MAIN_MENU
+ });
+ return;
+ }
+
+ var loggedInAdmin = {
+ email:adminUser.email,
+ password:adminUser.password,
+ privilege:adminUser.privilege
+ }
+ req.session.loggedInAdmin = loggedInAdmin;
+ console.log("Login Success"+JSON.stringify(loggedInAdmin));
+ res.redirect('sla/listSLA');
+ }else{
+ res.render("pages/err",
+ {
+ result:
+ {
+ code:'error',
+ msg:'User ' + attuid + ' is not in the database. Please see an adminstrator to have them added.'
+ },
+ header:process.env.MAIN_MENU
+ });
+ }
+ });
+}
+
+function checkAuth(req,res,next){
+ var host = req.get('host');
+ var url = req.url;
+ var originalUrl = req.originalUrl;
+
+ console.log("checkAuth");
+
+ var host = req.headers['host'];
+console.log('host=' + host);
+
+ console.log("cookie is not null "+JSON.stringify(req.session.loggedInAdmin));
+ if(req.session == null || req.session == undefined
+ || req.session.loggedInAdmin == null || req.session.loggedInAdmin == undefined)
+ {
+ // nothing else to do but log them back in, or they may
+ // be coming from the graph tool
+ console.log("loggedInAdmin not found.session timed out.");
+ res.render('pages/login');
+ return false;
+ }
+ next();
+}
+
+exports.login = login;
+exports.logout = logout;
+exports.checkAuth = checkAuth;