model = new Admin(); $this->JumpUrl = '/admin/index'; } /** * 登录函数 * @return Response * @throws OperateException * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function index(): Response { // 禁止重复访问 $adminInfo = get_admin_info(); if (isset($adminInfo['id'])) { return $this->redirect('/admin/index'); } if (request()->isPost()) { $user = request()->post('name'); $pwd = request()->post('pwd'); $captcha = request()->post('captcha'); validate(\app\common\validate\system\Admin::class)->scene('login')->check([ 'name' => $user, 'pwd' => $pwd, ]); LoginService::accountLogin($user, $pwd, $captcha, $adminInfo); return $this->success('登录成功!', $this->JumpUrl); } return view('login/index', [ 'captcha' => $session['isCaptcha'] ?? false, ]); } }