retrieve jws token from env config
parent
fdb81bdeda
commit
ebfaa7afb1
|
@ -14,8 +14,6 @@ const checkAdmin = require('../middleware/permission-check').checkAdmin;
|
|||
// HTTP status codes by name
|
||||
const codes = require('./http-codes');
|
||||
|
||||
const config = require('../config/config');
|
||||
|
||||
const routerHandling = require('../middleware/router-handling');
|
||||
|
||||
const AppUserModel = require('../models/app-user');
|
||||
|
@ -57,12 +55,13 @@ let authCheck = (username, password, res) => {
|
|||
}
|
||||
if (user && user.activated && bcrypt.compareSync(password, user.password)) {
|
||||
// authentication successful
|
||||
var secret = process.env.JWS_SECRET;
|
||||
deferred.resolve({
|
||||
_id: user._id,
|
||||
username: user.username,
|
||||
permission: user.permission,
|
||||
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)
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue