-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add the status "deleted" to the user table #529
Conversation
Signed-off-by: bidi <[email protected]>
Signed-off-by: bidi <[email protected]>
Signed-off-by: bidi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- With these modifications, trying to authenticate with a deleted account (I know it's an edge-case, but we need to handle it properly) will throw this message:
User account must be activated first.
In order to fix this, we should modify config/autoload/authentication.global.php
and make sure that status is not Deleted
, but we cannot add a(nother) rule for status
because we already have one that checks if user is Pending
.
One solution would be to modify src/User/src/Adapter/AuthenticationAdapter.php
and add after if (null === $identityClass)
the following:
$methodName = 'isDeleted';
$this->checkMethod($identityClass, $methodName);
if ($identityClass->$methodName()) {
return new Result(
Result::FAILURE_IDENTITY_NOT_FOUND,
null,
[Message::ACCOUNT_NOT_FOUND]
);
}
UserService
->find*
methods must make sure that they do not return deleted users.
For example:
public function findByUuid(string $uuid): ?User
{
return $this->userRepository->findByUuid($uuid);
}
would become:
public function findByUuid(string $uuid): ?User
{
$user = $this->userRepository->findByUuid($uuid);
if (! $user instanceof User) {
return null;
}
if ($user->isDeleted()) {
return null;
}
return $user;
}
Similar approach for the other find*
methods.
- Not being restricted anymore by a boolean field in the database, we can also simplify usage of
User::IS_DELETED
andUser::IS_DELETED_*
Signed-off-by: bidi <[email protected]>
Signed-off-by: bidi <[email protected]>
Signed-off-by: bidi <[email protected]>
No description provided.