Skip to content

[19.0][MIG] auth_signup_verify_email: Migration to 19.0 - #905

Open
F4LC0NN wants to merge 35 commits into
OCA:19.0from
F4LC0NN:19.0-mig-auth_signup_verify_email
Open

F4LC0NN wants to merge 35 commits into
OCA:19.0from
F4LC0NN:19.0-mig-auth_signup_verify_email

Conversation

@F4LC0NN

@F4LC0NN F4LC0NN commented Feb 25, 2026

Copy link
Copy Markdown

auth_signup_verify_email: Migration to 19.0

  • Fixed signup xml template for the login field
  • Fixed translations symbol in main.py to adapt to version 19.0 specifications
  • Fixed cursor invocation from env in main.py according to version 19.0 specifications

yajo and others added 30 commits February 25, 2026 08:18
* 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/

@F4LC0NN F4LC0NN left a comment

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.

Auto Review OK

@kwoychesko

Copy link
Copy Markdown

Thanks for the migration, @F4LC0NN! One thing worth flagging on the view — I think it's a behavioral regression in 19.0:

only_passwords was removed from auth_signup core in 19.0. In 18.0 the auth_signup.signup and auth_signup.reset_password templates set it (<t t-set="only_passwords" .../>), but those t-sets are gone in 19.0 and the variable isn't defined anywhere now. So the t-if="only_passwords" added here resolves against an undefined name, which QWeb renders as falsy (no error) — meaning the password / confirm-password fields end up always hidden.

Since auth_signup.fields is also rendered (with a token) on the reset-password page and on invited/token signup, this hides the password inputs there too: a user following a password-reset link or an invitation link gets a form with no password fields and can't set a password. The two tests don't catch it because neither renders the token/password-fields state.

A fix that preserves the passwordless-for-uninvited behavior without relying on the removed flag — gate the fields call on a valid token instead:

<template id="signup_fields" inherit_id="auth_signup.signup">
    <!-- show password fields only for invited/token signups; uninvited = passwordless -->
    <xpath expr="//t[@t-call='auth_signup.fields']" position="attributes">
        <attribute name="t-if">token and not invalid_token</attribute>
    </xpath>
    <xpath expr="//input[@name='login']" position="attributes">
        <attribute name="type">email</attribute>
    </xpath>
</template>

This leaves auth_signup.reset_password's own (already token-gated) call to auth_signup.fields untouched, so password reset and invited signup keep working. Verified on 19.0.

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

conflicts.

@mav-adhoc

Copy link
Copy Markdown

only_passwords does not exist in Odoo 19 or 20, so the password fields this
module hides are 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 therefore cannot be completed: the user
gets the mail, opens the link, and has no field to set a password.

Odoo 18 defined the variable in two places, both dropped in 19:

  • auth_signup.signup: <t t-set="only_passwords" t-value="bool(token and not invalid_token)"/>
  • auth_signup.reset_password: <t t-set="only_passwords" t-value="1"/>

Nothing defines only_passwords in 19.0 or 20.0, core or enterprise. QWeb
resolves an unknown name to a falsy value without raising, so the module does
not fail — it silently hides the fields.

Measured on a 20.0 database with the module installed, on the combined arch of
auth_signup.fields:

name="password" name="confirm_password"
as-is, with token absent absent
as-is, without token absent absent
t-if="token and not invalid_token", with token present present
t-if="token and not invalid_token", without token absent absent

Using token and not invalid_token in both xpaths restores the 18.0 behaviour.
Same result with auth_password_policy_signup installed, which inherits the
same template.

The module's tests only exercise /web/signup (alert-danger for a bad address,
alert-success for a good one), so they pass either way — which is why CI is
green.

Found while migrating the module to 20.0 on top of this PR; not touching the code here.

@les-adhoc

Copy link
Copy Markdown

We opened #1080 with these commits rebased on 19.0 and the only_passwords fix. If you prefer to add the fix here, we can close ours.

@mav-adhoc

Copy link
Copy Markdown

Heads-up on two issues in passwordless_signup, found while reviewing the 20.0 migration (#1064). I found them by reading the code; I did not reproduce them on 19.0.

  1. Signup disabled is not enforced. web_auth_signup sends any POST with login and no password to passwordless_signup() before core checks signup_enabled. So on a database with free signup disabled (b2b), an anonymous POST to /web/signup still creates a portal user.
  2. All request params reach a sudo copy(). values = request.params is passed whole to signup(), which, without a token, ends up in a sudo copy() of the template user. Extra POST params (e.g. ref) are written to the new user.

#1064 fixes both for 20.0: it runs core's guards first (404 when signup is disabled, error on an invalid token) and only passes login, name, email and an empty password, with tests. The same change applies here: https://github.com/OCA/server-auth/pull/1064/files

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.