diff options
Diffstat (limited to 'app/Controller/Auth.php')
| -rw-r--r-- | app/Controller/Auth.php | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php index 95ad8d9e..46b5a546 100644 --- a/app/Controller/Auth.php +++ b/app/Controller/Auth.php @@ -2,8 +2,6 @@ namespace Kanboard\Controller; -use Gregwar\Captcha\CaptchaBuilder; - /** * Authentication controller * @@ -23,8 +21,8 @@ class Auth extends Base $this->response->redirect($this->helper->url->to('app', 'index')); } - $this->response->html($this->template->layout('auth/index', array( - 'captcha' => isset($values['username']) && $this->authentication->hasCaptcha($values['username']), + $this->response->html($this->helper->layout->app('auth/index', array( + 'captcha' => ! empty($values['username']) && $this->userLocking->hasCaptcha($values['username']), 'errors' => $errors, 'values' => $values, 'no_layout' => true, @@ -40,16 +38,11 @@ class Auth extends Base public function check() { $values = $this->request->getValues(); - list($valid, $errors) = $this->authentication->validateForm($values); + $this->sessionStorage->hasRememberMe = ! empty($values['remember_me']); + list($valid, $errors) = $this->authValidator->validateForm($values); if ($valid) { - if (! empty($this->session['login_redirect']) && ! filter_var($this->session['login_redirect'], FILTER_VALIDATE_URL)) { - $redirect = $this->session['login_redirect']; - unset($this->session['login_redirect']); - $this->response->redirect($redirect); - } - - $this->response->redirect($this->helper->url->to('app', 'index')); + $this->redirectAfterLogin(); } $this->login($values, $errors); @@ -62,23 +55,27 @@ class Auth extends Base */ public function logout() { - $this->authentication->backend('rememberMe')->destroy($this->userSession->getId()); - $this->session->close(); - $this->response->redirect($this->helper->url->to('auth', 'login')); + if (! DISABLE_LOGOUT) { + $this->sessionManager->close(); + $this->response->redirect($this->helper->url->to('auth', 'login')); + } else { + $this->response->redirect($this->helper->url->to('auth', 'index')); + } } /** - * Display captcha image + * Redirect the user after the authentication * - * @access public + * @access private */ - public function captcha() + private function redirectAfterLogin() { - $this->response->contentType('image/jpeg'); + if (isset($this->sessionStorage->redirectAfterLogin) && ! empty($this->sessionStorage->redirectAfterLogin) && ! filter_var($this->sessionStorage->redirectAfterLogin, FILTER_VALIDATE_URL)) { + $redirect = $this->sessionStorage->redirectAfterLogin; + unset($this->sessionStorage->redirectAfterLogin); + $this->response->redirect($redirect); + } - $builder = new CaptchaBuilder; - $builder->build(); - $this->session['captcha'] = $builder->getPhrase(); - $builder->output(); + $this->response->redirect($this->helper->url->to('app', 'index')); } } |
