Commit 4f2bf853 authored by Fintan Mc Gee's avatar Fintan Mc Gee

moved create use functionality under admin view

parent 3f0d9e91
......@@ -2,4 +2,27 @@
<H2 class = "centered"><span>Administration View</span></H2>
<div class ="centeredDiv" id="graphDiv"></div>
<ng-include src="'/admin/html/templates/userData.html'"></ng-include>
<div class="row">
<div class="container">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<form action="/submitNewUser" method="post" class="form-signin">
<div>
<label>New Username:</label>
<input class="form-control inputName" type="text" name="username" placeholder="User name" required autofocus/>
<br/>
</div>
<div>
<label>Password:</label>
<input type="password" name="password" class="form-control inputPassword" placeholder="User password" required/>
</div>
<div>
<button class="btn btn-lg btn-default btn-signin " type="submit">Create user</button>
</div>
</form>
</div>
<div class="col-sm-4"></div>
</div>
</div>
<div id="tooltip"></div>
......@@ -154,7 +154,7 @@ var newUser_cb = function (req, res) {
* @param next a placeholder for next function to be called if using function chaining
*/
var submitNewUser_cb = function (req, res, next) {
sLog.debug_log("New Login POST received");
sLog.debug_log("New create user POST received");
blizaarSystem.createNewUser(req.body.username, req.body.password);
......@@ -165,18 +165,12 @@ var submitNewUser_cb = function (req, res, next) {
}
if (!user) {
req.session.messages = [ info.message ];
sLog.log("no user specified");
//sLog.log("no user specified");
return res.redirect('/#/admin');
return res.redirect('/login');
}
req.logIn(user, function (err) {
if (err) {
return next(err);
}
sLog.debug_log("Login successful for user " + user.username);
return res.redirect('/');
});
})(req, res, next);
};
/** @function updateUser_cb
......@@ -850,8 +844,8 @@ var getBarChartAttributes_cb = function (req,res) {
* User Login Functionality *
*/
simple_serve.post('/submitLogin', submitLogin_cb );
simple_serve.post('/newuser', newUser_cb);
simple_serve.post('/submitNewUser', submitNewUser_cb);
//simple_serve.post('/newuser', newUser_cb);
simple_serve.post('/submitNewUser', blizaarSystem.ensureAuthenticated, blizaarSystem.ensureAdmin, submitNewUser_cb);
simple_serve.post('/updateUser', blizaarSystem.ensureAuthenticated, blizaarSystem.ensureAdmin, updateUser_cb);
simple_serve.get('/login',login_cb);
simple_serve.get('/loginFailure', loginFailure_cb);
......
......@@ -240,9 +240,9 @@
<button class="btn btn-lg btn-default btn-signin " type="submit">Submit</button>
</div>
</form>
<form action="/newuser" method="post" class="form-signin">
<button class="btn btn-lg btn-default btn-signin " type="submit">Never been here ?</button>
</form>
<!--<form action="/newuser" method="post" class="form-signin">-->
<!--<button class="btn btn-lg btn-default btn-signin " type="submit">Never been here ?</button>-->
<!--</form>-->
</p>
</div>
</div>
......
......@@ -200,7 +200,7 @@ function createNewUser(userName, userPassword,dataGroup) {
sLog.log(userName+" user already exists" ,"system.js" ,err);
} else {
sLog.debug_log.log('user: ' + newUser.username + " saved.","system.js" );
sLog.debug_log('user: ' + newUser.username + " saved.","system.js" );
}
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment