example/index.js
function processToken(token, done) {
    var user = _.find(users, function (item) {
        return item.username === token[claims.username];
    });
    if (!user) {
        user = {
            id          : token[claims.id] || currId++,
            username    : token[claims.username],
            email       : token[claims.email],
            firstName   : token[claims.firstName],
            lastName    : token[claims.lastName]
        };
        var roles = token[claims.role];
        if (!roles) {
            roles = ["guest"];
        } else if (!(roles instanceof Array)) {
            roles = [roles];
        }
        user.roles = roles;
        users.push(user);
    }
    done(null, user);
}
function processToken(token, done) {
    var user = _.find(users, function (item) {
        return item.username === token[claims.username];
    });
    if (!user) {
        user = {
            id          : token[claims.id] || currId++,
            username    : token[claims.username],
            email       : token[claims.email],
            firstName   : token[claims.firstName],
            lastName    : token[claims.lastName]
        };
        var roles = token[claims.role];
        if (!roles) {
            roles = ["guest"];
        } else if (!(roles instanceof Array)) {
            roles = [roles];
        }
        user.roles = roles;
        users.push(user);
    }
    done(null, user);
}
function processToken ( token , done ) { var user = _ . find ( users , function ( item ) { return item . username === token [ claims . username ] ; } ) ; if ( ! user ) { user = { id : token [ claims . id ] || currId ++ , username : token [ claims . username ] , email : token [ claims . email ] , firstName : token [ claims . firstName ] , lastName : token [ claims . lastName ] } ; var roles = token [ claims . role ] ; if ( ! roles ) { roles = [ "guest" ] ; } else if ( ! ( roles instanceof Array ) ) { roles = [ roles ] ; } user . roles = roles ; users . push ( user ) ; } done ( null , user ) ; }
We have to build and register the user with the supplied claims from the access token. The token could be either Simple Web Token or JSON Web Token by specification.
We have to build and register the user with the supplied claims from the access token . The token could be either Simple Web Token or JSON Web Token by specification .