summaryrefslogtreecommitdiff
path: root/app/Auth
diff options
context:
space:
mode:
Diffstat (limited to 'app/Auth')
-rw-r--r--app/Auth/Database.php14
-rw-r--r--app/Auth/GitHub.php14
-rw-r--r--app/Auth/Google.php14
-rw-r--r--app/Auth/Ldap.php11
-rw-r--r--app/Auth/RememberMe.php10
-rw-r--r--app/Auth/ReverseProxy.php12
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;
}