Commit cf39f1b8 by feixiang

user初始化

parent ffaa1eaa
......@@ -129,25 +129,7 @@ class User
public function setToken($value)
{
if ( empty($value) ) {
return [false,AuthError::GET_TOKEN_ERROR];
}
/**
* @var Redis $redis
*/
$redis = App::getBean(Redis::class);
$info = $redis->get('AUTH:'.$value);
if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER];
}
$info = json_decode($info, true);
$this->fill($info);
$this->token = $value;
return true;
}
public function setCmId($value)
......@@ -199,6 +181,29 @@ class User
}
public function initUser()
{
if ( empty($value) ) {
return [false,AuthError::GET_TOKEN_ERROR];
}
/**
* @var Redis $redis
*/
$redis = App::getBean(Redis::class);
$info = $redis->get('AUTH:'.$value);
if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER];
}
$info = json_decode($info, true);
$this->fill($info);
return true;
}
}
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