diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 21:11:11 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 21:11:11 -0500 |
commit | 88d84073aecbe8bdc5f10825b6d7ca6b81c5f7b1 (patch) | |
tree | e823c8e13e9ffba115c8e1f5a05a514cac5322df /app/Auth | |
parent | 0a14c8d5e5538e487dd6b012771f72aea6f4d5a6 (diff) |
Add more subscribers
Diffstat (limited to 'app/Auth')
-rw-r--r-- | app/Auth/Database.php | 14 | ||||
-rw-r--r-- | app/Auth/GitHub.php | 14 | ||||
-rw-r--r-- | app/Auth/Google.php | 14 | ||||
-rw-r--r-- | app/Auth/Ldap.php | 11 | ||||
-rw-r--r-- | app/Auth/RememberMe.php | 10 | ||||
-rw-r--r-- | app/Auth/ReverseProxy.php | 12 |
6 files changed, 14 insertions, 61 deletions
diff --git a/app/Auth/Database.php b/app/Auth/Database.php index 47dc8e6e..bdb2aeb6 100644 --- a/app/Auth/Database.php +++ b/app/Auth/Database.php @@ -3,7 +3,7 @@ namespace Auth; use Model\User; -use Core\Request; +use Event\AuthEvent; /** * Database authentication @@ -33,18 +33,8 @@ class Database extends Base $user = $this->db->table(User::TABLE)->eq('username', $username)->eq('is_ldap_user', 0)->findOne(); if ($user && password_verify($password, $user['password'])) { - - // Update user session $this->user->updateSession($user); - - // Update login history - $this->lastLogin->create( - self::AUTH_NAME, - $user['id'], - Request::getIpAddress(), - Request::getUserAgent() - ); - + $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id'])); return true; } diff --git a/app/Auth/GitHub.php b/app/Auth/GitHub.php index 034f9260..a785c494 100644 --- a/app/Auth/GitHub.php +++ b/app/Auth/GitHub.php @@ -2,7 +2,7 @@ namespace Auth; -use Core\Request; +use Event\AuthEvent; use OAuth\Common\Storage\Session; use OAuth\Common\Consumer\Credentials; use OAuth\Common\Http\Uri\UriFactory; @@ -35,18 +35,8 @@ class GitHub extends Base $user = $this->user->getByGitHubId($github_id); if ($user) { - - // Create the user session $this->user->updateSession($user); - - // Update login history - $this->lastLogin->create( - self::AUTH_NAME, - $user['id'], - Request::getIpAddress(), - Request::getUserAgent() - ); - + $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id'])); return true; } diff --git a/app/Auth/Google.php b/app/Auth/Google.php index 587ecde1..f779cfe5 100644 --- a/app/Auth/Google.php +++ b/app/Auth/Google.php @@ -2,7 +2,7 @@ namespace Auth; -use Core\Request; +use Event\AuthEvent; use OAuth\Common\Storage\Session; use OAuth\Common\Consumer\Credentials; use OAuth\Common\Http\Uri\UriFactory; @@ -36,18 +36,8 @@ class Google extends Base $user = $this->user->getByGoogleId($google_id); if ($user) { - - // Create the user session $this->user->updateSession($user); - - // Update login history - $this->lastLogin->create( - self::AUTH_NAME, - $user['id'], - Request::getIpAddress(), - Request::getUserAgent() - ); - + $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id'])); return true; } diff --git a/app/Auth/Ldap.php b/app/Auth/Ldap.php index 82307e8c..b3c998f9 100644 --- a/app/Auth/Ldap.php +++ b/app/Auth/Ldap.php @@ -2,7 +2,7 @@ namespace Auth; -use Core\Request; +use Event\AuthEvent; /** * LDAP model @@ -55,14 +55,7 @@ class Ldap extends Base // We open the session $this->user->updateSession($user); - - // Update login history - $this->lastLogin->create( - self::AUTH_NAME, - $user['id'], - Request::getIpAddress(), - Request::getUserAgent() - ); + $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id'])); return true; } diff --git a/app/Auth/RememberMe.php b/app/Auth/RememberMe.php index cb8a9b44..9f2bb13a 100644 --- a/app/Auth/RememberMe.php +++ b/app/Auth/RememberMe.php @@ -3,6 +3,7 @@ namespace Auth; use Core\Request; +use Event\AuthEvent; use Core\Security; /** @@ -103,12 +104,9 @@ class RememberMe extends Base $this->user->updateSession($this->user->getById($record['user_id'])); $this->acl->isRememberMe(true); - // Update last login infos - $this->lastLogin->create( - self::AUTH_NAME, - $this->acl->getUserId(), - Request::getIpAddress(), - Request::getUserAgent() + $this->container['dispatcher']->dispatch( + 'auth.success', + new AuthEvent(self::AUTH_NAME, $this->acl->getUserId()) ); return true; diff --git a/app/Auth/ReverseProxy.php b/app/Auth/ReverseProxy.php index 23e71a22..9d766a5b 100644 --- a/app/Auth/ReverseProxy.php +++ b/app/Auth/ReverseProxy.php @@ -2,7 +2,7 @@ namespace Auth; -use Core\Request; +use Event\AuthEvent; /** * ReverseProxy backend @@ -37,16 +37,8 @@ class ReverseProxy extends Base $user = $this->user->getByUsername($login); } - // Create the user session $this->user->updateSession($user); - - // Update login history - $this->lastLogin->create( - self::AUTH_NAME, - $user['id'], - Request::getIpAddress(), - Request::getUserAgent() - ); + $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id'])); return true; } |