moving jwt and login related things to new auth module
This commit is contained in:
parent
1b7092fd34
commit
91a4e06cb7
17
freechat-client/src/auth.js
Normal file
17
freechat-client/src/auth.js
Normal file
@ -0,0 +1,17 @@
|
||||
const jsonwebtoken = require('jsonwebtoken')
|
||||
|
||||
/**
|
||||
* Checks to see if the jwt is not expired basically
|
||||
*
|
||||
* @param {String} jwt token string to verify
|
||||
* @returns Boolean
|
||||
*/
|
||||
exports.valid_jwt = function (jwt) {
|
||||
const result = jsonwebtoken.decode(jwt)
|
||||
if(result) {
|
||||
const now = Math.floor(Date.now() / 1000)
|
||||
return result['exp'] > now // does it expire later?
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user