mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
fix: blocked users from accessing console
This commit is contained in:
parent
14a243cc37
commit
4748dedd29
1 changed files with 18 additions and 16 deletions
|
|
@ -563,25 +563,27 @@ App::init()
|
||||||
throw new AppwriteException(AppwriteException::GENERAL_UNAUTHORIZED_SCOPE, $user->getAttribute('email', 'User') . ' (role: ' . \strtolower($roles[$role]['label']) . ') missing scope (' . $scope . ')');
|
throw new AppwriteException(AppwriteException::GENERAL_UNAUTHORIZED_SCOPE, $user->getAttribute('email', 'User') . ' (role: ' . \strtolower($roles[$role]['label']) . ') missing scope (' . $scope . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === $user->getAttribute('status')) { // Account is blocked
|
if (in_array('api', $route->getGroups())) {
|
||||||
throw new AppwriteException(AppwriteException::USER_BLOCKED);
|
if (false === $user->getAttribute('status')) { // Account is blocked
|
||||||
}
|
throw new AppwriteException(AppwriteException::USER_BLOCKED);
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->getAttribute('reset')) {
|
if ($user->getAttribute('reset')) {
|
||||||
throw new AppwriteException(AppwriteException::USER_PASSWORD_RESET_REQUIRED);
|
throw new AppwriteException(AppwriteException::USER_PASSWORD_RESET_REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode !== APP_MODE_ADMIN) {
|
if ($mode !== APP_MODE_ADMIN) {
|
||||||
$mfaEnabled = $user->getAttribute('mfa', false);
|
$mfaEnabled = $user->getAttribute('mfa', false);
|
||||||
$hasVerifiedAuthenticator = $user->getAttribute('totpVerification', false);
|
$hasVerifiedAuthenticator = $user->getAttribute('totpVerification', false);
|
||||||
$hasVerifiedEmail = $user->getAttribute('emailVerification', false);
|
$hasVerifiedEmail = $user->getAttribute('emailVerification', false);
|
||||||
$hasVerifiedPhone = $user->getAttribute('phoneVerification', false);
|
$hasVerifiedPhone = $user->getAttribute('phoneVerification', false);
|
||||||
$hasMoreFactors = $hasVerifiedEmail || $hasVerifiedPhone || $hasVerifiedAuthenticator;
|
$hasMoreFactors = $hasVerifiedEmail || $hasVerifiedPhone || $hasVerifiedAuthenticator;
|
||||||
$minimumFactors = ($mfaEnabled && $hasMoreFactors) ? 2 : 1;
|
$minimumFactors = ($mfaEnabled && $hasMoreFactors) ? 2 : 1;
|
||||||
|
|
||||||
if (!in_array('mfa', $route->getGroups())) {
|
if (!in_array('mfa', $route->getGroups())) {
|
||||||
if ($session && \count($session->getAttribute('factors')) < $minimumFactors) {
|
if ($session && \count($session->getAttribute('factors')) < $minimumFactors) {
|
||||||
throw new AppwriteException(AppwriteException::USER_MORE_FACTORS_REQUIRED);
|
throw new AppwriteException(AppwriteException::USER_MORE_FACTORS_REQUIRED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue