Commit e5ab35cb by 庄欣

add icon

parent 3eedf286
...@@ -96,20 +96,12 @@ class User extends Controller ...@@ -96,20 +96,12 @@ class User extends Controller
*/ */
public function getUserIdByHashCode($code) public function getUserIdByHashCode($code)
{ {
$redis = mRedis::getRedis(); $user = UserModel::where("access_token",$code)->first();
$user = $redis->hGet(self::REDIS_AUTHKEY,$code); try {
if (!$user) { return Response::success($user['id']);
return Response::error("未登录",HttpStatus::HttpUnauthorized); } catch (\Exception) {
}
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);
return Response::error("未登录",HttpStatus::HttpUnauthorized); 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