auth = $this->getDI()->get('auth'); } public function register() { $service = new RegisterService(); $account = $service->handle(); $userRepo = new UserRepo(); $user = $userRepo->findById($account->id); $this->auth->saveAuthInfo($user); $this->eventsManager->fire('Account:afterRegister', $this, $user); return $user; } public function loginByPassword() { $post = $this->request->getPost(); $validator = new AccountValidator(); $user = $validator->checkUserLogin($post['account'], $post['password']); $validator = new CaptchaValidator(); $validator->checkCode($post['ticket'], $post['rand']); $this->auth->saveAuthInfo($user); $this->eventsManager->fire('Account:afterLogin', $this, $user); } public function loginByVerify() { $post = $this->request->getPost(); $validator = new AccountValidator(); $user = $validator->checkVerifyLogin($post['account'], $post['verify_code']); $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); } }