auth = $this->getDI()->get('auth'); } public function login() { $post = $this->request->getPost(); $validator = new AccountValidator(); $user = $validator->checkAdminLogin($post['account'], $post['password']); $validator->checkIfAllowLogin($user); $captcha = $this->getSettings('captcha'); /** * 验证码是一次性的,放到最后检查,减少第三方调用 */ if ($captcha['enabled'] == 1) { $validator = new CaptchaValidator(); $validator->checkCode($post['ticket'], $post['rand']); } $this->auth->saveAuthInfo($user); $this->eventsManager->fire('Account:afterLogin', $this, $user); } public function logout() { $user = $this->getLoginUser(); $this->auth->clearAuthInfo(); $this->eventsManager->fire('Account:afterLogout', $this, $user); } }