Check if user role has changed while the session is open
This commit is contained in:
parent
19ea9ed620
commit
61a55c8888
|
|
@ -84,7 +84,7 @@ class DatabaseAuth extends Base implements PasswordAuthenticationProviderInterfa
|
|||
*/
|
||||
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()
|
||||
{
|
||||
if (! $this->authenticationManager->checkCurrentSession()) {
|
||||
throw AccessForbiddenException::getInstance()->withoutLayout();
|
||||
$this->response->redirect($this->helper->url->to('AuthController', 'login'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->isPublicAccess()) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,15 @@ class UserModel extends Base
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue