Add more subscribers

This commit is contained in:
Frédéric Guillot
2014-12-27 21:11:11 -05:00
parent 0a14c8d5e5
commit 88d84073ae
13 changed files with 101 additions and 65 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}