function authentication(req, res, next) {
    Logger.info('Authenticating'); /** @todo Remove */
    let token = null;
    let apiToken = false;
    if (req.jwt && req.jwt.payload.firebaseToken) {
        token = req.jwt.payload.firebaseToken;
        apiToken = true;
        next();
        return;
    } else {
        token = (req.jwt && req.jwt.token) ? req.jwt.token : null;
    }
    if (!token) {
        next(new UnauthenticatedError(codes._40));
        return;
    }
    if (_.isString(token)) {
        admin.auth().verifyIdToken(token).then(info => {
            Logger.info('User authenticated'); /** @todo Remove */
            next();
            return;
        }).catch(error => {
            Logger.warn('Firebase failed to authenticate token');
            next(new UnauthenticatedError(codes._41));
            return;
        });
    } else {
        next(new UnauthenticatedError(codes._42));
        return;
    }

}
/**
 * This methods authenticates a user using the Firebase Authentication Admin Library.
 * If the user is successfully authenticated the express next function is called to forwarding the request to the relevant handler.
 * If the user is not authenticated an express response is sent back with a 401 header.
 * @param {object} req - Express request object. 
 * @param {object} res - Express response object.
 * @param {Function} next - Express next function
 */
This methods authenticates a user using the Firebase Authentication Admin Library.
If the user is successfully authenticated the express next function is called to forwarding the request to the relevant handler.
If the user is not authenticated an express response is sent back with a 401 header.
@param {object} req - Express request object.
@param {object} res - Express response object.
@param {Function} next - Express next function
This methods authenticates a user using the Firebase Authentication Admin Library . If the user is successfully authenticated the express next function is called to forwarding the request to the relevant handler . If the user is not authenticated an express response is sent back with a 401 header . @param { object } req - Express request object . @param { object } res - Express response object . @param { Function } next - Express next function
function authentication(req, res, next) {
    Logger.info('Authenticating'); 
    let token = null;
    let apiToken = false;
    if (req.jwt && req.jwt.payload.firebaseToken) {
        token = req.jwt.payload.firebaseToken;
        apiToken = true;
        next();
        return;
    } else {
        token = (req.jwt && req.jwt.token) ? req.jwt.token : null;
    }
    if (!token) {
        next(new UnauthenticatedError(codes._40));
        return;
    }
    if (_.isString(token)) {
        admin.auth().verifyIdToken(token).then(info => {
            Logger.info('User authenticated'); 
            next();
            return;
        }).catch(error => {
            Logger.warn('Firebase failed to authenticate token');
            next(new UnauthenticatedError(codes._41));
            return;
        });
    } else {
        next(new UnauthenticatedError(codes._42));
        return;
    }
}
function authentication ( req , res , next ) { Logger . info ( 'Authenticating' ) ; let token = null ; let apiToken = false ; if ( req . jwt && req . jwt . payload . firebaseToken ) { token = req . jwt . payload . firebaseToken ; apiToken = true ; next ( ) ; return ; } else { token = ( req . jwt && req . jwt . token ) ? req . jwt . token : null ; } if ( ! token ) { next ( new UnauthenticatedError ( codes . _40 ) ) ; return ; } if ( _ . isString ( token ) ) { admin . auth ( ) . verifyIdToken ( token ) . then ( info => { Logger . info ( 'User authenticated' ) ; next ( ) ; return ; } ) . catch ( error => { Logger . warn ( 'Firebase failed to authenticate token' ) ; next ( new UnauthenticatedError ( codes . _41 ) ) ; return ; } ) ; } else { next ( new UnauthenticatedError ( codes . _42 ) ) ; return ; } }
This methods authenticates a user using the Firebase Authentication Admin Library.
This methods authenticates a user using the Firebase Authentication Admin Library .
/** @todo Remove */ /** @todo Remove */