diff options
author | diosmosis <benaka@piwik.pro> | 2014-09-28 15:19:30 +0400 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-09-28 15:19:30 +0400 |
commit | c7b287c012f34f81f4fb19115b80d6bffcb9f122 (patch) | |
tree | a74b7da8f355014a0f62de60193e261ebf627df1 /plugins/Login/Controller.php | |
parent | 3a6ca2319d4ee570f2258dc7d4b9ad229bc7b443 (diff) |
Refactor Auth::initSession method into its own class (SessionInitializer) since the logic will be common to all authentication implementations. Includes tweak to docs of UsersManager API method and additional methods to Auth interface.
Diffstat (limited to 'plugins/Login/Controller.php')
-rw-r--r-- | plugins/Login/Controller.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index 525e98a555..82ae9ccab2 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -13,6 +13,7 @@ use Piwik\Auth as AuthInterface; use Piwik\Common; use Piwik\Config; use Piwik\Cookie; +use Piwik\Log; use Piwik\Nonce; use Piwik\Piwik; use Piwik\QuickForm2; @@ -20,8 +21,6 @@ use Piwik\Session; use Piwik\Url; use Piwik\View; -require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; - /** * Login controller * @@ -39,12 +38,18 @@ class Controller extends \Piwik\Plugin\Controller private $auth; /** + * @var SessionInitializer + */ + private $sessionInitializer; + + /** * Constructor. * * @param PasswordResetter $passwordResetter * @param AuthInterface $auth + * @param SessionInitializer $authenticatedSessionFactory \ */ - public function __construct($passwordResetter = null, $auth = null) + public function __construct($passwordResetter = null, $auth = null, $sessionInitializer = null) { parent::__construct(); @@ -57,6 +62,11 @@ class Controller extends \Piwik\Plugin\Controller $auth = \Piwik\Registry::get('auth'); } $this->auth = $auth; + + if (empty($sessionInitializer)) { + $sessionInitializer = new SessionInitializer(); + } + $this->sessionInitializer = $sessionInitializer; } /** @@ -168,7 +178,8 @@ class Controller extends \Piwik\Plugin\Controller } else { $this->auth->setPasswordHash($password); } - $this->auth->initSession($rememberMe); + + $this->sessionInitializer->initSession($this->auth, $rememberMe); // remove password reset entry if it exists $this->passwordResetter->removePasswordResetInfo($login); @@ -236,6 +247,8 @@ class Controller extends \Piwik\Plugin\Controller try { $this->passwordResetter->initiatePasswordResetProcess($loginMail, $password); } catch (Exception $ex) { + Log::debug($ex); + return array($ex->getMessage()); } @@ -256,6 +269,8 @@ class Controller extends \Piwik\Plugin\Controller try { $this->passwordResetter->confirmNewPassword($login, $resetToken); } catch (Exception $ex) { + Log::debug($ex); + $errorMessage = $ex->getMessage(); } @@ -315,4 +330,4 @@ class Controller extends \Piwik\Plugin\Controller Url::redirectToUrl($logoutUrl); } } -} +}
\ No newline at end of file |