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