Check if user role has changed while the session is open
This commit is contained in:
@@ -84,7 +84,7 @@ class DatabaseAuth extends Base implements PasswordAuthenticationProviderInterfa
|
|||||||
*/
|
*/
|
||||||
public function isValidSession()
|
public function isValidSession()
|
||||||
{
|
{
|
||||||
return $this->userModel->isActive($this->userSession->getId());
|
return $this->userModel->isValidSession($this->userSession->getId(), $this->userSession->getRole());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ class AuthenticationMiddleware extends BaseMiddleware
|
|||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
if (! $this->authenticationManager->checkCurrentSession()) {
|
if (! $this->authenticationManager->checkCurrentSession()) {
|
||||||
throw AccessForbiddenException::getInstance()->withoutLayout();
|
$this->response->redirect($this->helper->url->to('AuthController', 'login'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->isPublicAccess()) {
|
if (! $this->isPublicAccess()) {
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ class UserModel extends Base
|
|||||||
*/
|
*/
|
||||||
const EVERYBODY_ID = -1;
|
const EVERYBODY_ID = -1;
|
||||||
|
|
||||||
|
public function isValidSession($userID, $sessionRole)
|
||||||
|
{
|
||||||
|
return $this->db->table(self::TABLE)
|
||||||
|
->eq('id', $userID)
|
||||||
|
->eq('is_active', 1)
|
||||||
|
->eq('role', $sessionRole)
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the user exists
|
* Return true if the user exists
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user