diff options
| author | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
|---|---|---|
| committer | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
| commit | e4de6b3898b64b26d29aff31f21df5fda8055686 (patch) | |
| tree | 575f8a65440f291d70a070d168eafca8c82a6459 /app/Controller/Auth.php | |
| parent | d9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff) | |
| parent | a6540bc604c837d92c9368540c145606723e97f7 (diff) | |
Merge pull request #1 from fguillot/master
Update from upstream
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')); } } |
