update 登录接口 缓存token
This commit is contained in:
parent
ac992fc93f
commit
3b59a6203c
@ -5,29 +5,20 @@ use app\common\repositories\user\UserRepository;
|
|||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use think\App;
|
use think\App;
|
||||||
|
|
||||||
|
use think\facade\Cache;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
|
|
||||||
class Login extends BaseController
|
class Login extends BaseController
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var repository
|
|
||||||
*/
|
|
||||||
protected $repository;
|
|
||||||
|
|
||||||
public $areaCode; // 区县地区码
|
|
||||||
|
|
||||||
public $streetCode; // 镇街道地区码
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(App $app)
|
public function __construct(App $app)
|
||||||
{
|
{
|
||||||
parent::__construct($app);
|
parent::__construct($app);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login(UserRepository $repository)
|
public function login()
|
||||||
{
|
{
|
||||||
$account = $this->request->post('account', '');
|
$account = $this->request->post('account', '');
|
||||||
$password = $this->request->post('password', '');
|
$password = $this->request->post('password', '');
|
||||||
@ -47,6 +38,8 @@ class Login extends BaseController
|
|||||||
|
|
||||||
$expire = time()+ 3600 * 24;
|
$expire = time()+ 3600 * 24;
|
||||||
$token = md5($expire);
|
$token = md5($expire);
|
||||||
|
// 缓存token
|
||||||
|
Cache::set($token.'_'.$user['uid'], $expire);
|
||||||
return app('json')->success(compact('user','token', 'expire'));
|
return app('json')->success(compact('user','token', 'expire'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user