public static < T extends Model > T getLoginWithDb ( HttpServletRequest req , HttpServletResponse response , Function < Long , T > function ) { T loginUser = getLoginUser ( req ) ; if ( loginUser == null ) { //从Cookie中解析出用户id CookieUser cookie_user = getUserFromCookie ( req ) ; if ( cookie_user == null ) return null ; T user = CacheKit . get ( LOGIN_CACHE_SESSION , LOGIN_CACHE_SESSION + cookie_user . getId ( ) ) ; if ( user == null ) { user = function . apply ( cookie_user . getId ( ) ) ; CacheKit . put ( LOGIN_CACHE_SESSION , LOGIN_CACHE_SESSION + cookie_user . getId ( ) , user ) ; } // 用户密码和cookie中存储的密码一致 if ( user != null && StringUtils . equalsIgnoreCase ( user . getStr ( "password" ) , cookie_user . getPassword ( ) ) ) { setLoginMember ( req , response , user , true ) ; return user ; } else { return null ; } } else { return loginUser ; } }
Get user login information if the session does not exist then try to obtain from the Cookie if cookie exists then decrypt obtain user information .