fix(Token): make new scope future compatible

- "password-unconfirmable" is the effective name for 30, but a draft
  name was backported.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
pull/45704/head
Arthur Schiwon 2024-06-12 11:05:43 +07:00
parent 86a496d589
commit 4ec174197f
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
4 changed files with 4 additions and 4 deletions

@ -103,7 +103,7 @@ class PasswordConfirmationMiddleware extends Middleware {
return;
}
$scope = $token->getScopeAsArray();
if (isset($scope['sso-based-login']) && $scope['sso-based-login'] === true) {
if (isset($scope['password-unconfirmable']) && $scope['password-unconfirmable'] === true) {
// Users logging in from SSO backends cannot confirm their password by design
return;
}

@ -310,6 +310,6 @@ class JSConfigHelper {
return true;
}
$scope = $token->getScopeAsArray();
return !isset($scope['sso-based-login']) || $scope['sso-based-login'] === false;
return !isset($scope['password-unconfirmable']) || $scope['password-unconfirmable'] === false;
}
}

@ -200,7 +200,7 @@ class OC_User {
if (empty($password)) {
$tokenProvider = \OC::$server->get(IProvider::class);
$token = $tokenProvider->getToken($userSession->getSession()->getId());
$token->setScope(['sso-based-login' => true]);
$token->setScope(['password-unconfirmable' => true]);
$tokenProvider->updateToken($token);
}

@ -198,7 +198,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
$token = $this->createMock(IToken::class);
$token->method('getScopeAsArray')
->willReturn(['sso-based-login' => true]);
->willReturn(['password-unconfirmable' => true]);
$this->tokenProvider->expects($this->once())
->method('getToken')
->with($sessionId)