Skip to content
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

Merged
merged 6 commits into from
Dec 17, 2024
Merged

add the status "deleted" to the user table #529

merged 6 commits into from
Dec 17, 2024

Conversation

bidi47
Copy link
Member

@bidi47 bidi47 commented Dec 10, 2024

No description provided.

Copy link

github-actions bot commented Dec 10, 2024

Qodana for PHP

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 105 dependencies

Third-party software list

This page lists the third-party software dependencies used in project

Dependency Version Licenses
brick/math 0.12.1 MIT
brick/varexporter 0.5.0 MIT
doctrine/collections 2.2.2 MIT
doctrine/common 3.4.5 MIT
doctrine/data-fixtures 1.8.1 MIT
doctrine/dbal 4.2.1 MIT
doctrine/deprecations 1.1.4 MIT
doctrine/event-manager 2.0.1 MIT
doctrine/inflector 2.0.10 MIT
doctrine/instantiator 2.0.0 MIT
doctrine/lexer 3.0.1 MIT
doctrine/migrations 3.8.2 MIT
doctrine/orm 3.3.0 MIT
doctrine/persistence 3.4.0 MIT
dotkernel/dot-authentication 2.4.0 MIT
dotkernel/dot-authorization 3.5.2 MIT
dotkernel/dot-cache 4.1.0 MIT
dotkernel/dot-controller 3.5.1 MIT
dotkernel/dot-data-fixtures 1.2.3 MIT
dotkernel/dot-dependency-injection 1.1.0 MIT
dotkernel/dot-errorhandler 4.0.0 MIT
dotkernel/dot-event 3.4.2 MIT
dotkernel/dot-flashmessenger 3.5.0 MIT
dotkernel/dot-helpers 3.6.0 MIT
dotkernel/dot-log 4.0.4 MIT
dotkernel/dot-mail 5.1.0 MIT
dotkernel/dot-navigation 3.5.1 MIT
dotkernel/dot-rbac-guard 3.5.0 MIT
dotkernel/dot-rbac 3.6.0 MIT
dotkernel/dot-response-header 3.4.0 MIT
dotkernel/dot-session 5.6.0 MIT
dotkernel/dot-twigrenderer 3.5.1 MIT
egulias/email-validator 4.0.2 MIT
fig/http-message-util 1.1.5 MIT
friendsofphp/proxy-manager-lts v1.0.18 MIT
laminas/laminas-authentication 2.16.0 BSD-3-Clause
laminas/laminas-code 4.16.0 BSD-3-Clause
laminas/laminas-component-installer 3.5.0 BSD-3-Clause
laminas/laminas-config-aggregator 1.17.0 BSD-3-Clause
laminas/laminas-diactoros 3.5.0 BSD-3-Clause
laminas/laminas-escaper 2.14.0 BSD-3-Clause
laminas/laminas-eventmanager 3.14.0 BSD-3-Clause
laminas/laminas-filter 2.39.0 BSD-3-Clause
laminas/laminas-form 3.21.0 BSD-3-Clause
laminas/laminas-httphandlerrunner 2.11.0 BSD-3-Clause
laminas/laminas-hydrator 4.16.0 BSD-3-Clause
laminas/laminas-i18n 2.29.0 BSD-3-Clause
laminas/laminas-inputfilter 2.31.0 BSD-3-Clause
laminas/laminas-json 3.7.1 BSD-3-Clause
laminas/laminas-permissions-rbac 3.7.0 BSD-3-Clause
laminas/laminas-servicemanager 3.23.0 BSD-3-Clause
laminas/laminas-session 2.22.0 BSD-3-Clause
laminas/laminas-stdlib 3.20.0 BSD-3-Clause
laminas/laminas-stratigility 3.13.0 BSD-3-Clause
laminas/laminas-translator 1.1.0 BSD-3-Clause
laminas/laminas-validator 2.64.2 BSD-3-Clause
laminas/laminas-view 2.36.0 BSD-3-Clause
mezzio/mezzio-authentication 1.10.0 BSD-3-Clause
mezzio/mezzio-authorization-rbac 1.8.0 BSD-3-Clause
mezzio/mezzio-authorization 1.10.0 BSD-3-Clause
mezzio/mezzio-cors 1.13.0 BSD-3-Clause
mezzio/mezzio-fastroute 3.12.0 BSD-3-Clause
mezzio/mezzio-helpers 5.17.0 BSD-3-Clause
mezzio/mezzio-router 3.18.0 BSD-3-Clause
mezzio/mezzio-template 2.11.0 BSD-3-Clause
mezzio/mezzio-twigrenderer 2.17.0 BSD-3-Clause
mezzio/mezzio 3.20.1 BSD-3-Clause
nikic/fast-route v1.3.0 BSD-3-Clause
nikic/php-parser v5.3.1 BSD-3-Clause
psr/cache 3.0.0 MIT
psr/container 1.1.2 MIT
psr/event-dispatcher 1.0.0 MIT
psr/http-client 1.0.3 MIT
psr/http-factory 1.1.0 MIT
psr/http-message 2.0 MIT
psr/http-server-handler 1.0.2 MIT
psr/http-server-middleware 1.0.2 MIT
psr/log 3.0.2 MIT
ramsey/collection 2.0.0 MIT
ramsey/uuid-doctrine 2.1.0 MIT
ramsey/uuid 4.7.6 MIT
roave/psr-container-doctrine 5.2.2 BSD-2-Clause
symfony/cache-contracts v3.5.1 MIT
symfony/cache v7.2.1 MIT
symfony/console v7.2.1 MIT
symfony/deprecation-contracts v3.5.1 MIT
symfony/event-dispatcher-contracts v3.5.1 MIT
symfony/event-dispatcher v7.2.0 MIT
symfony/filesystem v7.2.0 MIT
symfony/mailer v7.1.6 MIT
symfony/mime v7.2.1 MIT
symfony/polyfill-ctype v1.31.0 MIT
symfony/polyfill-intl-grapheme v1.31.0 MIT
symfony/polyfill-intl-idn v1.31.0 MIT
symfony/polyfill-intl-normalizer v1.31.0 MIT
symfony/polyfill-mbstring v1.31.0 MIT
symfony/polyfill-php80 v1.31.0 MIT
symfony/polyfill-php81 v1.31.0 MIT
symfony/service-contracts v3.5.1 MIT
symfony/stopwatch v7.2.0 MIT
symfony/string v7.2.0 MIT
symfony/var-exporter v7.2.0 MIT
twig/twig v3.17.1 BSD-3-Clause
webimpress/safe-writer 2.2.0 BSD-2-Clause
webmozart/assert 1.11.0 MIT
Contact Qodana team

Contact us at [email protected]

@bidi47 bidi47 requested a review from alexmerlin December 10, 2024 15:19
@bidi47 bidi47 linked an issue Dec 10, 2024 that may be closed by this pull request
Copy link
Member

@alexmerlin alexmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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]
    );
}

  1. 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.


  1. Not being restricted anymore by a boolean field in the database, we can also simplify usage of User::IS_DELETED and User::IS_DELETED_*

src/User/src/Controller/AccountController.php Outdated Show resolved Hide resolved
src/User/src/Controller/AccountController.php Outdated Show resolved Hide resolved
src/User/src/Service/UserService.php Outdated Show resolved Hide resolved
src/User/src/Service/UserService.php Outdated Show resolved Hide resolved
@bidi47 bidi47 requested a review from alexmerlin December 11, 2024 16:06
src/User/src/Service/UserService.php Outdated Show resolved Hide resolved
src/User/src/Service/UserService.php Outdated Show resolved Hide resolved
src/User/src/Service/UserService.php Outdated Show resolved Hide resolved
src/User/src/Service/UserService.php Show resolved Hide resolved
Signed-off-by: bidi <[email protected]>
@bidi47 bidi47 requested a review from alexmerlin December 16, 2024 10:14
@arhimede arhimede merged commit 79301f1 into 5.0 Dec 17, 2024
24 checks passed
@arhimede arhimede added this to the 5.1.0 milestone Dec 17, 2024
@alexmerlin alexmerlin deleted the issue-523 branch December 17, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add the status "deleted" to the user table
3 participants