GoalModelEditor/BackEnd/routes/authen.js
/** Authenticate the jwt token
 * @param headers : the http request headers containing 'Authorization'
 * @return true : token is valid
 * @return false : token id invalid
 */
Authenticate the jwt token
@param headers : the http request headers containing 'Authorization'
@return true : token is valid
@return false : token id invalid
Authenticate the jwt token @param headers : the http request headers containing ' Authorization ' @return true : token is valid @return false : token id invalid
function authenticate(headers) {
    let authString = headers["Authorization"];
    if (!authString) {
        return false;
    }
    let token = authString.split(" ")[1];
    try {
        let decoded = jwt.verify(token, SECRET);
    } catch (err) {
        return false;
    }
    return true;
}
function authenticate ( headers ) { let authString = headers [ "Authorization" ] ; if ( ! authString ) { return false ; } let token = authString . split ( " " ) [ 1 ] ; try { let decoded = jwt . verify ( token , SECRET ) ; } catch ( err ) { return false ; } return true ; }
Authenticate the jwt token
 @param headers : the http request headers containing 'Authorization'
 @return true : token is valid
 @return false : token id invalid
Authenticate the jwt token @param headers : the http request headers containing ' Authorization ' @return true : token is valid @return false : token id invalid
// TODO: return id to check authorization