mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-05 09:42:47 +08:00
feat: 实现token认证机制
This commit is contained in:
@@ -5,6 +5,7 @@ namespace base\admin\controller;
|
||||
use app\admin\model\SystemAdmin;
|
||||
use app\common\controller\AdminController;
|
||||
use think\captcha\facade\Captcha;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Env;
|
||||
use think\facade\Event;
|
||||
use think\facade\Session;
|
||||
@@ -80,9 +81,11 @@ class LoginBase extends AdminController
|
||||
unset($admin['password']);
|
||||
$admin['expire_time'] = $post['keep_login'] == 1 ? true : time() + 7200;
|
||||
session('admin', $admin);
|
||||
$token = md5(uniqid());
|
||||
Cache::set($token, $admin, $post['keep_login'] == 1 ? time() + 86400 * 7 : time() + 7200);
|
||||
|
||||
Session::delete('back-url');
|
||||
$this->success('登录成功', '', $back_url);
|
||||
$this->success('登录成功', ['token' => $token], $back_url);
|
||||
}
|
||||
$this->assign('captcha', $captcha);
|
||||
$this->assign('demo', $this->isDemo);
|
||||
|
||||
Reference in New Issue
Block a user