app/assist/status.js
//checking for moderator and him/her status for admin's pages
checking for moderator and him/her status for admin's pages
checking for moderator and him / her status for admin ' s pages
function checking(need_status) {
    return function(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) {
                errors.e403(req, res, next);
            }
            db.admins.findOne({where: {
                name: name_arr[0],
                active: 1
            }}).then(function(moderator) {
                if(moderator && name_arr[1] == req.ip && need_status <= moderator.status) {
                    res.modId = moderator.id;
                    res.modStatus = moderator.status;
                    res.locals.modStatus = moderator.status;
                    next();
                }
                else {
                    errors.e403(req, res, next);
                }
            }, function(err) {
                console.log(err);
                errors.e500(req, res, next);
            });
        }
        else {
            errors.e403(req, res, next);
        }
    }
}
function checking ( need_status ) { return function ( 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 ) { errors . e403 ( req , res , next ) ; } db . admins . findOne ( { where : { name : name_arr [ 0 ] , active : 1 } } ) . then ( function ( moderator ) { if ( moderator && name_arr [ 1 ] == req . ip && need_status <= moderator . status ) { res . modId = moderator . id ; res . modStatus = moderator . status ; res . locals . modStatus = moderator . status ; next ( ) ; } else { errors . e403 ( req , res , next ) ; } } , function ( err ) { console . log ( err ) ; errors . e500 ( req , res , next ) ; } ) ; } else { errors . e403 ( req , res , next ) ; } } }
checking for moderator and him/her status for admin's pages
checking for moderator and him / her status for admin ' s pages
//search moderator's cookie //decrypt //separation name and IP //request to DB