1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 13:51:37 +08:00
2020-03-30 19:35:49 +08:00

64 lines
1.1 KiB
PHP

<?php
namespace App\Services\AuthUser;
use App\Models\User as UserModel;
use App\Services\AuthUser;
class Home extends AuthUser
{
/**
* 写入会话
*
* @param UserModel $user
*/
public function saveAuthInfo(UserModel $user)
{
$authKey = $this->getAuthKey();
$authUser = new \stdClass();
$authUser->id = $user->id;
$authUser->name = $user->name;
$authUser->avatar = $user->avatar;
$authUser->admin_role = $user->admin_role;
$authUser->edu_role = $user->edu_role;
$this->session->set($authKey, $authUser);
}
/**
* 清除会话
*/
public function clearAuthInfo()
{
$authKey = $this->getAuthKey();
$this->session->remove($authKey);
}
/**
* 读取会话
*
* @return mixed
*/
public function getAuthInfo()
{
$authKey = $this->getAuthKey();
return $this->session->get($authKey);
}
/**
* 获取会话键值
*
* @return string
*/
public function getAuthKey()
{
return 'user_info';
}
}