Commit e5ab35cb by 庄欣

add icon

parent 3eedf286
......@@ -96,20 +96,12 @@ class User extends Controller
*/
public function getUserIdByHashCode($code)
{
$redis = mRedis::getRedis();
$user = $redis->hGet(self::REDIS_AUTHKEY,$code);
if (!$user) {
return Response::error("未登录",HttpStatus::HttpUnauthorized);
}
if (isset($user['expire']) && time() > strtotime($user['expire']."+ 1 day")) {
$redis->hDel(self::REDIS_AUTHKEY,$code);
return Response::error("已过期",HttpStatus::HttpUnauthorized);
}
if (!isset($user['id'])) {
$redis->hDel(self::REDIS_AUTHKEY,$code);
$user = UserModel::where("access_token",$code)->first();
try {
return Response::success($user['id']);
} catch (\Exception) {
return Response::error("未登录",HttpStatus::HttpUnauthorized);
}
return Response::success($user['id']);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment