retrieve jws token from env config

pull/26/head
HardiReady 2018-02-03 21:41:38 +01:00
parent fdb81bdeda
commit ebfaa7afb1
1 changed files with 2 additions and 3 deletions

View File

@ -14,8 +14,6 @@ const checkAdmin = require('../middleware/permission-check').checkAdmin;
// HTTP status codes by name // HTTP status codes by name
const codes = require('./http-codes'); const codes = require('./http-codes');
const config = require('../config/config');
const routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
const AppUserModel = require('../models/app-user'); const AppUserModel = require('../models/app-user');
@ -57,12 +55,13 @@ let authCheck = (username, password, res) => {
} }
if (user && user.activated && bcrypt.compareSync(password, user.password)) { if (user && user.activated && bcrypt.compareSync(password, user.password)) {
// authentication successful // authentication successful
var secret = process.env.JWS_SECRET;
deferred.resolve({ deferred.resolve({
_id: user._id, _id: user._id,
username: user.username, username: user.username,
permission: user.permission, permission: user.permission,
squad: user.squad, squad: user.squad,
token: jwt.sign({sub: user._id}, config.secret, {expiresIn: diff * 60}), token: jwt.sign({sub: user._id}, secret, {expiresIn: diff * 60}),
tokenExpireDate: new Date(Date.now().valueOf() + diff * 60000 - 1000) tokenExpireDate: new Date(Date.now().valueOf() + diff * 60000 - 1000)
}); });
} else { } else {