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

[5.x]: Account activation redirects to /login instead of completing activation using autoLoginAfterAccountActivation #16357

Open
romainpoirier opened this issue Dec 24, 2024 · 0 comments
Labels

Comments

@romainpoirier
Copy link

What happened?

Description

Under Craft CMS 5.5.3 and associated plugins (see dependencies listed below), the account activation process consistently redirects users to /login, regardless of previous configurations or expectations. To further investigate, I tested avoiding the 404 error in devMode by creating a /login template and adding the line {{ d(currentUser) }} at the start. This consistently outputs null, which confirms that autoLoginAfterAccountActivation is not functioning as expected.

This issue occurs despite enabling the autoLoginAfterAccountActivation(true) configuration. The expected behavior is to redirect users to the e-shop/account/orders page (if logged in) or e-shop/account/sign-in page (if not logged in), without explicitly defining these paths. These are static paths unrelated to account activation, and this functionality worked without issue until now. Specifying the login URL via the loginPath configuration parameter does not resolve the problem either, and the activation process consistently redirects to /login.

In devMode, the following error appears:

yii\web\NotFoundHttpException: Page not found. in /var/www/html/vendor/craftcms/cms/src/web/Request.php:1412
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Application.php(82): craft\web\Request->resolve()
#1 /var/www/html/vendor/craftcms/cms/src/web/Application.php(318): yii\web\Application->handleRequest(Object(craft\web\Request))
#2 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#3 /var/www/html/htdocs/index.php(12): yii\base\Application->run()
#4 {main}

To avoid the 404 error in devMode, I created a /login template and added the following line at the beginning of the template:

{{ d(currentUser) }}

This outputs null, indicating that autoLoginAfterAccountActivation is not working as expected.

In production mode (with devMode disabled), the activation request does not throw visible errors but fails silently. These are static paths unrelated to account activation, and this functionality worked without issue until now. Specifying the login URL via the loginPath configuration parameter does not resolve the problem either. Logs anonymized for privacy (below) show a warning indicating a possible misconfiguration or resolution error.

Steps to reproduce

  1. Enable autoLoginAfterAccountActivation in the Craft CMS configuration.
  2. Attempt to activate a user account using the activation link sent via email.
  3. Observe that users are redirected to /login instead of completing the activation process.
  4. Check logs for relevant errors or warnings.

Expected behavior

  • Upon clicking the account activation link, the account should be activated successfully.
  • If the user is already logged in, they should be redirected to e-shop/account/orders.
  • If the user is not logged in, they should be redirected to e-shop/account/sign-in.
  • Explicit configuration of these paths should not be necessary, as they worked without issue previously.

Actual behavior

  • Clicking the activation link redirects to /login, regardless of user authentication status.
  • Activation does not complete successfully.
  • Errors in logs suggest a request resolution issue within the Craft CMS routing system.

Dependencies

"require": {
    "craftcms/ckeditor": "4.4.0",
    "craftcms/cms": "5.5.3",
    "craftcms/commerce": "5.2.6",
    "craftcms/commerce-stripe": "5.0.4.3",
    "craftcms/element-api": "^4.1",
    "craftcms/feed-me": "6.6.1",
    "mmikkel/cp-field-inspect": "2.0.2",
    "mmikkel/retcon": "3.2.1",
    "nystudio107/craft-instantanalytics-ga4": "5.0.1",
    "nystudio107/craft-minify": "5.0.0",
    "nystudio107/craft-retour": "5.0.4",
    "nystudio107/craft-seomatic": "5.1.8",
    "nystudio107/craft-typogrify": "5.0.1",
    "putyourlightson/craft-sprig": "3.5.1",
    "spacecatninja/imager-x": "5.1.0",
    "spatie/mjml-php": "^1.2",
    "spicyweb/craft-embedded-assets": "5.4.0",
    "studioespresso/craft-dumper": "5.0.1",
    "studioespresso/craft-mailersend": "5.0.0",
    "topshelfcraft/environment-label": "5.0.0",
    "ttempleton/craft-nocache": "3.0.4",
    "verbb/abandoned-cart": "4.0.3",
    "verbb/expanded-singles": "3.0.1",
    "verbb/queue-monitor": "^2.0.0",
    "verbb/smith": "3.1.0",
    "vlucas/phpdotenv": "^5.4.0",
    "voku/html-min": "^4.5",
    "yiisoft/yii2-redis": "^2.0"
}

Anonymized Logs

2024-12-24 12:22:35 [web.WARNING] [application] Request context: {"environment":"production","vars":{"_GET":{"code":"<activation_code>","id":"<user_id>"},"_POST":[],"_FILES":[],"_COOKIE":{"CraftSessionId":"<session_id>","_ia":"<ia_value>","CRAFT_CSRF_TOKEN":"<csrf_token>"},"_SESSION":{"error":"Erreur lors de l’activation de votre compte"},"_SERVER":{"REQUEST_URI":"/en/verifyemail?code=<activation_code>&id=<user_id>","REQUEST_METHOD":"GET","SERVER_PROTOCOL":"HTTP/1.1","CRAFT_ENVIRONMENT":"production","HTTP_HOST":"<host>","HTTPS":"on"}}}

Craft CMS version

5.5.3

PHP version

8.2.24

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant