app/assist/status_common.js
//checking for moderator and him/her status for common pages
checking for moderator and him/her status for common pages
checking for moderator and him / her status for common pages
function status_common(req, res, next) {
    if(req.cookies.hanako_admin) {
        var name = admin_crypt.decrypt(req.cookies.hanako_admin);
        var name_arr;
        try {
            name_arr = name.split('_');
        }
        catch(err) {
            next();
        }
        db.admins.findOne({where: {
            name: name_arr[0],
            active: 1
        }}).then(function(moderator) {
            if(moderator && name_arr[1] == req.ip) {
                res.locals.mod = {
                    id: moderator.id,
                    status: moderator.status,
                    boards: JSON.parse(moderator.boards || null)
                };
                res.modId = moderator.id;
                next();
            }
            else {
                next();
            }
        }, function(err) {
            console.log(err);
            next();
        });
    }
    else {
        next();
    }
}
function status_common ( req , res , next ) { if ( req . cookies . hanako_admin ) { var name = admin_crypt . decrypt ( req . cookies . hanako_admin ) ; var name_arr ; try { name_arr = name . split ( '_' ) ; } catch ( err ) { next ( ) ; } db . admins . findOne ( { where : { name : name_arr [ 0 ] , active : 1 } } ) . then ( function ( moderator ) { if ( moderator && name_arr [ 1 ] == req . ip ) { res . locals . mod = { id : moderator . id , status : moderator . status , boards : JSON . parse ( moderator . boards || null ) } ; res . modId = moderator . id ; next ( ) ; } else { next ( ) ; } } , function ( err ) { console . log ( err ) ; next ( ) ; } ) ; } else { next ( ) ; } }
checking for moderator and him/her status for common pages
checking for moderator and him / her status for common pages
//decrypt //separation name and IP //request to DB