Skip to content

[20.0][MIG] auth_signup_verify_email: Migration to 20.0 - #1064

Open
mav-adhoc wants to merge 38 commits into
OCA:20.0from
mav-adhoc:20.0-t-76669-mav
Open

mav-adhoc wants to merge 38 commits into
OCA:20.0from
mav-adhoc:20.0-t-76669-mav

Conversation

@mav-adhoc

@mav-adhoc mav-adhoc commented Nov 10, 2026 •

Copy link
Copy Markdown

Migration of auth_signup_verify_email to 20.0.

It carries the 19.0 migration too

The module is not in the 19.0 branch: its migration, #905, is still open, so
this PR is built on top of it. The history here is #905's plus one
[IMP] pre-commit auto fixes and one [MIG] … Migration to 20.0. The OCA
migration guide allows skipping a version when the intermediate guides' tasks
are done, and #905's [MIG] covers 19.0.

If #905 (or #1034, a second 19.0 migration of the same module) is merged first,
this PR should be rebased on it.

What 20.0 needed

  • ir.config_parameter.set_param is gone (odoo/odoo@a4f2879697a7), replaced by
    typed setters → set_str.
  • website.get_current_website is gone (odoo/odoo@2545a833c8e4). The
    replacement is the env.website property, with an explicit fallback, which is
    what core 20.0 does in website/models/ir_http.py.
  • The website model is now declared in base
    (odoo/addons/base/models/website.py), so "website" in self.env no longer
    tells whether the website module is installed. The test now checks for the
    field instead. Without this the two existing tests error with
    AttributeError: 'website' object has no attribute 'auth_signup_uninvited'.
    The default website record moved too: website.default_website →
    base.default_website.

Fix: the activation page had no password fields

only_passwords was dropped from core in 19.0, and the module still used it in
the t-if of the password fields, so they were hidden on every page that
renders auth_signup.fields — including /web/reset_password?token=..., which
is where this module's own activation mail points. Public signup could not be
completed. Details and measurements in
#905 (comment).

The xpaths now use token and not invalid_token, which is the expression Odoo
18 assigned to only_passwords. Behaviour is back to 18.0: fields shown with a
token, hidden on free signup.

test_activation_page_asks_for_password covers it — it signs up, prepares a
reset token and asserts the password inputs are on the page. Validated red →
green: without the fix only that test fails.

pre-commit

BLE001 and TRY401 fire in controllers/main.py on this branch. .ruff.toml
is identical in 19.0 and 20.0; what changed is the hook bump (ruff
v0.13.0 → v0.16.8), and since the config only sets extend-select, ruff's
wider default rule set now applies. Fixed in code so the check is green:
TRY401 by dropping the redundant exception object (logging.exception already
attaches it), BLE001 with a # noqa — narrowing the except Exception would
change behaviour, since an unexpected error would stop being rendered as a form
error. If OCA/oca-addons-repo-template#372 lands and the repo is updated, both
rules stop applying and the # noqa can go.

Review changes

Folded into the [MIG] commit:

  • The password xpath now requires label[@for='password'], since in 20.0
    auth_signup.fields nests a second div.field-password inside
    div.field-confirm_password.
  • signup_login_fields is removed: core 20.0 already renders type="email"
    on the signup login input.
  • The passwordless signup only runs on POST without a signup token. GET
    requests and token signups (activation, reset, invitation) go to core.
  • The values passed to signup() come from an allow-list (login, name,
    empty password) instead of all of request.params, which end up in a
    sudo copy() of the template user. The email is taken from login, so the
    activation mail can't be sent to another address. Core's guard runs first:
    404 when signup is disabled.
  • The request language is passed to signup(), as core's
    _prepare_signup_values does, so the activation email is not sent in the
    template user's language.
  • New tests: signup page without password fields, extra params (including
    email) ignored, 404 when signup is disabled, duplicate email rejected, GET
    never signs up, token signups left to core.

Notes for reviewers

  • No migration script. The module defines no models or fields and has no
    data//demo/. 19.0 mig auth signup verify email #1034 adds an upgrades/ script that drops stale
    website-specific copies of auth_signup.signup, because they broke
    validation of signup_login_fields. That view is gone; the only remaining
    view inherits auth_signup.fields, so the script is not needed here.

The original [MIG] changes were installed and tested on a clean 20.0
database with demo data, with auth_password_policy_signup also installed. The
review changes were not run locally; CI covers them.

yajo and others added 30 commits November 6, 2026 15:45
* Add module auth_signup_verify_email.

* Import module following guidelines.

* README typos.

* OCA Transbot updated translations from Transifex

* Credit creator.

* author name correction

* [9.0][MIG][auth_signup_verify_email] Migration.

Migrate to v9.

* [FIX] auth_signup_verify_email: Python library requirement

* Add tests, fix xml tags, fix credits.

* Fix test.
* Module set to installable
* Odoo don't let signup without password
…ts and use email_validator (OCA#29)

This addon introduced an integration conflict when tested in a database that had `mail_tracking_mass_mailing` installed, producing this failure:

    Traceback (most recent call last):
    File "/opt/odoo/auto/addons/auth_signup_verify_email/controllers/main.py", line 44, in passwordless_signup
        sudo_users.reset_password(values.get("login"))
    File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
        self.gen.next()
    File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 419, in savepoint
        self.execute('RELEASE SAVEPOINT "%s"' % name)
    File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 154, in wrapper
        return f(self, *args, **kwargs)
    File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 231, in execute
        res = self._obj.execute(query, params)
    InternalError: no such savepoint

Which in turn produced the following in the next test:

    InternalError: current transaction is aborted, commands ignored until end of transaction block

The problem comes from the fact that one cannot rollback to a nested savepoint if the parent savepoint was released. It became a problem because that's the strategy that both this addon and upstream's `TestCursor` follow.

To avoid that, tests now mock the `send_mail` method. This results also in having a predictable outcome from the test `test_good_email`, so it is more meaningful now.

Besides, previously we were using the `validate_email` package, which is currently a dead project that can silently fail under certain environments, as seen in syrusakbary/validate_email#80.

There's the `email_validator` package, freely available, supported, and it provides a human-readable error message whenever some format from the email fails.

As such, here I'm switching the dependency, while still adding a backwards compatibility layer for preexisting installations.
* When try to login with a not valid email domain it raised a 500 server
  error. Now we shwt the proper message "The domain name <domain> does not
  exist."
* If there is any error we do not have catched when we do the email
  validation then we manage it and show the error message to the user instead
  of 500 server error.
* When we try to register with a already registered email it raise "Something
  went wrong, please try again later or contact us". Now shows the message
  as odoo regular signup does: "Another user is already registered using this
  email address" which is more specific and clear for this case.
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-12.0/server-auth-12.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-12-0/server-auth-12-0-auth_signup_verify_email/pt_BR/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-12.0/server-auth-12.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-12-0/server-auth-12-0-auth_signup_verify_email/hr/
This commit fixes 2 problems:

1.  `auth_signup.allow_uninvited` ICP is no longer used.
    The new equivalent is `auth_signup.invitation_scope=b2c`.
2.  If running tests in an environment where `website` is installed,
    the website needs to get public signup enabled or tests here would
    fail with an error like this:

        2020-02-19 12:36:31,686 35 INFO prod odoo.modules.module: odoo.addons.auth_signup_verify_email.tests.test_verify_email running tests.
        2020-02-19 12:36:31,686 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: test_bad_email (odoo.addons.auth_signup_verify_email.tests.test_verify_email.UICase)
        2020-02-19 12:36:31,686 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` Test rejection of bad emails.
        2020-02-19 12:36:31,735 35 INFO ? odoo.http: HTTP Configuring static files
        2020-02-19 12:36:31,738 35 INFO prod odoo.addons.base.models.ir_http: Generating routing map
        2020-02-19 12:36:34,227 35 INFO prod werkzeug: 127.0.0.1 - - [19/Feb/2020 12:36:34] "GET /web/signup HTTP/1.1" 404 - 763 0.262 2.227
        2020-02-19 12:36:34,231 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ERROR
        2020-02-19 12:36:34,231 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: test_good_email (odoo.addons.auth_signup_verify_email.tests.test_verify_email.UICase)
        2020-02-19 12:36:34,231 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` Test acceptance of good emails.
        2020-02-19 12:36:36,293 35 INFO prod werkzeug: 127.0.0.1 - - [19/Feb/2020 12:36:36] "GET /web/signup HTTP/1.1" 404 - 759 0.258 1.797
        2020-02-19 12:36:36,296 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ERROR
        2020-02-19 12:36:36,297 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ======================================================================
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ERROR: test_bad_email (odoo.addons.auth_signup_verify_email.tests.test_verify_email.UICase)
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` Test rejection of bad emails.
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: Traceback (most recent call last):
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `   File "/opt/odoo/auto/addons/auth_signup_verify_email/tests/test_verify_email.py", line 20, in setUp
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `     "csrf_token": self.csrf_token(),
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `   File "/opt/odoo/auto/addons/auth_signup_verify_email/tests/test_verify_email.py", line 33, in csrf_token
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `     return doc.xpath("//input[@name='csrf_token']")[0].get("value")
        2020-02-19 12:36:36,297 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` IndexError: list index out of range
        2020-02-19 12:36:36,297 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ======================================================================
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ERROR: test_good_email (odoo.addons.auth_signup_verify_email.tests.test_verify_email.UICase)
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` Test acceptance of good emails.
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: Traceback (most recent call last):
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `   File "/opt/odoo/auto/addons/auth_signup_verify_email/tests/test_verify_email.py", line 20, in setUp
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `     "csrf_token": self.csrf_token(),
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `   File "/opt/odoo/auto/addons/auth_signup_verify_email/tests/test_verify_email.py", line 33, in csrf_token
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: `     return doc.xpath("//input[@name='csrf_token']")[0].get("value")
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: ` IndexError: list index out of range
        2020-02-19 12:36:36,298 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: Ran 2 tests in 4.611s
        2020-02-19 12:36:36,298 35 ERROR prod odoo.addons.auth_signup_verify_email.tests.test_verify_email: FAILED
        2020-02-19 12:36:36,298 35 INFO prod odoo.addons.auth_signup_verify_email.tests.test_verify_email:  (errors=2)
        2020-02-19 12:36:36,298 35 ERROR prod odoo.modules.module: Module auth_signup_verify_email: 0 failures, 2 errors

@Tecnativa TT21005
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-13.0/server-auth-13.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-13-0/server-auth-13-0-auth_signup_verify_email/ar/
In one part of the CI pipeline, the IANA example domains are not
accepted, getting this message from `email_validator` library:

The domain name example.com does not accept email

So we switch to a real domain for avoiding the problem, using our
famous main OCA list address, which at the end, it's not secret and
won't be disabled in a short future.
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-16.0/server-auth-16.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-16-0/server-auth-16-0-auth_signup_verify_email/es/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-17.0/server-auth-17.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_signup_verify_email/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-17.0/server-auth-17.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_signup_verify_email/it/
Currently translated at 100.0% (4 of 4 strings)

Translation: server-auth-17.0/server-auth-17.0-auth_signup_verify_email
Translate-URL: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_signup_verify_email/fi/
@oca-cla-bot

oca-cla-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@OCA-git-bot OCA-git-bot added mod:auth_signup_verify_email Module auth_signup_verify_email series:20.0 labels Nov 10, 2026
@mav-adhoc mav-adhoc mentioned this pull request Nov 10, 2026
12 tasks
@weinni2000

Copy link
Copy Markdown

Hi @F4LC0NN, @jr2-adhoc and @em230418 👋

This PR carries over the history of auth_signup_verify_email, including commits you authored in earlier migrations (19.0, 18.0, and 13.0–15.0). The CLA check is failing because the following commit emails aren't covered by a signed OCA Contributor License Agreement yet:

Could you sign the CLA here: https://clabot.odoo-community.org/ ? If you're covered by your company's corporate CLA, please ask them to add these email addresses to it.

Thank you!

@weinni2000 weinni2000 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked the 20.0 changes against odoo/odoo@20.0 and they look right. Bringing the password fields back on the activation page is the key fix, and the new test covers it.

Small changes needed:

  1. views/signup.xml: in 20.0, auth_signup.fields has a second div.field-password inside div.field-confirm_password, so //div[hasclass('field-password')] matches two nodes. It only works because inheritance takes the first one. Please make it specific, e.g. //div[hasclass('field-password')][label[@for='password']].
  2. views/signup.xml: core 20.0 already sets type="email" on the signup login input, so signup_login_fields does nothing and can be removed.
  3. tests/test_verify_email.py: replace the try/except ImportError block that imports patch twice with a plain from unittest.mock import patch.

To make reviewing easier:

  • weinni2000#1 shows only the 20.0 migration commit (base: the pre-commit commit), without the carried-over history.
  • weinni2000#2 applies these suggestions on top of this PR's head. It also includes a few optional extras: allow-listing the values passed to signup(), the 404 when signup is disabled, and more tests. Feel free to cherry-pick.

@em230418

Copy link
Copy Markdown

Feel free to relicense my past contributions on auth_signup_verify_email to LGPL if required.

@mav-adhoc

Copy link
Copy Markdown
Author

Thanks for the review, @weinni2000! Applied in two commits on top of the [MIG]:

  • [IMP] … address 20.0 review: unambiguous password xpath, signup_login_fields removed, plain patch import.
  • [FIX] … harden passwordless signup: your optional extras (allow-listed signup values, core's guards, and the new tests).

The combined diff matches your weinni2000#2. No migration script needed now that signup_login_fields is gone.

@mav-adhoc

Copy link
Copy Markdown
Author

Small correction to my previous comment: the review changes ended up in the single [MIG] commit, not in two separate commits.

I also pushed [IMP] auth_signup_verify_email: test password fields on every token page. It tests the password fields on the reset password and invitation pages too, and checks that they stay hidden with an invalid token. These are the same tests as the 19.0 fix (#1080), so both branches stay aligned.

@chienandalu chienandalu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Security issues in the passwordless signup, details inline.

class SignupVerifyEmail(AuthSignupHome):
@route()
def web_auth_signup(self, *args, **kw):
if request.params.get("login") and not request.params.get("password"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This also runs on GET (no captcha nor CSRF) and with a token (signup() then overwrites the existing user's password and email). Only for POST without token:

Suggested change
if request.params.get("login") and not request.params.get("password"):
if (
request.httprequest.method == "POST"
and not self.get_auth_signup_qcontext().get("token")
and request.params.get("login")
and not request.params.get("password")
):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, applied: the passwordless branch now only runs on POST without a token; GET and token signups go to core. Squashed into the [MIG] commit, with tests for both cases.

values = {
"login": login,
"name": request.params.get("name"),
"email": request.params.get("email") or login,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The activation mail goes to this address, so email=attacker@... gets the victim's link. signup() already takes it from login:

Suggested change
"email": request.params.get("email") or login,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, removed. signup() now takes the email from login, and a test checks that a posted email is ignored.

@chienandalu chienandalu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I hit approve instead of request changes 😅

The tests only checked the activation link. The view also decides the
password fields on the reset password and invitation pages, and must keep
them hidden when the token is invalid. Cover those pages too, with the
same tests as the 19.0 fix, so both branches stay aligned.

@chienandalu chienandalu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks :)

@chienandalu

Copy link
Copy Markdown
Member

@yajo could you review and check if you find it ok?

MT-16501

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.