mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
fix(Accounts): Add back v2 scope migration
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
c8a12a54fd
commit
bede81391b
2 changed files with 24 additions and 4 deletions
|
|
@ -132,7 +132,9 @@ class AccountManager implements IAccountManager {
|
|||
$property->setScope(self::SCOPE_LOCAL);
|
||||
}
|
||||
} else {
|
||||
$property->setScope($property->getScope());
|
||||
// migrate scope values to the new format
|
||||
// invalid scopes are mapped to a default value
|
||||
$property->setScope(AccountProperty::mapScopeToV2($property->getScope()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,11 +55,16 @@ class AccountProperty implements IAccountProperty {
|
|||
* @since 15.0.0
|
||||
*/
|
||||
public function setScope(string $scope): IAccountProperty {
|
||||
if (!in_array($scope, IAccountManager::ALLOWED_SCOPES, )) {
|
||||
$newScope = $this->mapScopeToV2($scope);
|
||||
if (!in_array($newScope, [
|
||||
IAccountManager::SCOPE_LOCAL,
|
||||
IAccountManager::SCOPE_FEDERATED,
|
||||
IAccountManager::SCOPE_PRIVATE,
|
||||
IAccountManager::SCOPE_PUBLISHED
|
||||
])) {
|
||||
throw new InvalidArgumentException('Invalid scope');
|
||||
}
|
||||
/** @var IAccountManager::SCOPE_* $scope */
|
||||
$this->scope = $scope;
|
||||
$this->scope = $newScope;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +105,19 @@ class AccountProperty implements IAccountProperty {
|
|||
return $this->scope;
|
||||
}
|
||||
|
||||
public static function mapScopeToV2(string $scope): string {
|
||||
if (str_starts_with($scope, 'v2-')) {
|
||||
return $scope;
|
||||
}
|
||||
|
||||
return match ($scope) {
|
||||
'private', '' => IAccountManager::SCOPE_LOCAL,
|
||||
'contacts' => IAccountManager::SCOPE_FEDERATED,
|
||||
'public' => IAccountManager::SCOPE_PUBLISHED,
|
||||
default => $scope,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verification status of a property
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue