moving jwt and login related things to new auth module

This commit is contained in:
shockrah 2021-01-28 17:55:26 -08:00
parent 1b7092fd34
commit 91a4e06cb7

View 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;
}
}