summaryrefslogtreecommitdiff
path: root/app/Auth/Database.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Auth/Database.php')
-rw-r--r--app/Auth/Database.php27
1 files changed, 11 insertions, 16 deletions
diff --git a/app/Auth/Database.php b/app/Auth/Database.php
index 47dc8e6e..e69f18a9 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
@@ -30,21 +30,16 @@ class Database extends Base
*/
public function authenticate($username, $password)
{
- $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()
- );
-
+ $user = $this->db
+ ->table(User::TABLE)
+ ->eq('username', $username)
+ ->eq('disable_login_form', 0)
+ ->eq('is_ldap_user', 0)
+ ->findOne();
+
+ if (is_array($user) && password_verify($password, $user['password'])) {
+ $this->userSession->refresh($user);
+ $this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;
}