From c18056889001bae2231f1e39a747f981e20217ca Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 7 Apr 2022 06:19:11 +0000 Subject: [PATCH 1/4] [IMP] portal: improve the "reset password" flow Bug === Improve the UI and the message displayed in the "reset password flow". Task-2629544 Part-of: odoo/odoo#78298 --- addons/auth_signup/controllers/main.py | 2 +- addons/auth_signup/models/res_users.py | 2 +- addons/auth_signup/views/auth_signup_login_templates.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index a7069fbabe0..f3afc75911d 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -84,7 +84,7 @@ class AuthSignupHome(Home): "Password reset attempt for <%s> by user <%s> from %s", login, request.env.user.login, request.httprequest.remote_addr) request.env['res.users'].sudo().reset_password(login) - qcontext['message'] = _("An email has been sent with credentials to reset your password") + qcontext['message'] = _("Password reset instructions sent to your email") except UserError as e: qcontext['error'] = e.args[0] except SignupError: diff --git a/addons/auth_signup/models/res_users.py b/addons/auth_signup/models/res_users.py index 8dbc67273dc..72860e96ba5 100644 --- a/addons/auth_signup/models/res_users.py +++ b/addons/auth_signup/models/res_users.py @@ -156,7 +156,7 @@ class ResUsers(models.Model): if not users: users = self.search([('email', '=', login)]) if len(users) != 1: - raise Exception(_('Reset password: invalid username or email')) + raise Exception(_('No account found for this login')) return users.action_reset_password() def action_reset_password(self): diff --git a/addons/auth_signup/views/auth_signup_login_templates.xml b/addons/auth_signup/views/auth_signup_login_templates.xml index 19273d6760b..390982beccb 100644 --- a/addons/auth_signup/views/auth_signup_login_templates.xml +++ b/addons/auth_signup/views/auth_signup_login_templates.xml @@ -65,7 +65,7 @@

- Back to Login + Back to Login
@@ -91,7 +91,7 @@ - +
@@ -553,7 +553,7 @@
- +
From e46a04ce30b70540733383d466b76f088100a5d2 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Mon, 11 Apr 2022 11:29:44 +0000 Subject: [PATCH 3/4] [IMP] auth_password_policy: show the password meter only when needed Bug === The password meter is not super pretty, so we display it only when needed. Task-2629544 Part-of: odoo/odoo#78298 --- addons/auth_password_policy/static/src/css/password_field.css | 4 ++++ addons/auth_password_policy/static/src/js/password_gauge.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/addons/auth_password_policy/static/src/css/password_field.css b/addons/auth_password_policy/static/src/css/password_field.css index a819c39bc03..760cba94313 100644 --- a/addons/auth_password_policy/static/src/css/password_field.css +++ b/addons/auth_password_policy/static/src/css/password_field.css @@ -14,3 +14,7 @@ meter.o_password_meter { /* also input has a 5px bottom margin... */ bottom: calc(50% - 7px + 5px) } + +input + meter.o_password_meter[length="0"] { + display: none; +} diff --git a/addons/auth_password_policy/static/src/js/password_gauge.js b/addons/auth_password_policy/static/src/js/password_gauge.js index b655463b7ed..c78843dd026 100644 --- a/addons/auth_password_policy/static/src/js/password_gauge.js +++ b/addons/auth_password_policy/static/src/js/password_gauge.js @@ -111,6 +111,7 @@ var PasswordPolicyMeter = Widget.extend({ low: 0.5, high: 0.99, max: 1, + length: 0, value: 0, optimum: 1, }, @@ -133,6 +134,7 @@ var PasswordPolicyMeter = Widget.extend({ * @param {String} password */ update: function (password) { + this.el.setAttribute('length', password.length); this.el.value = policy.computeScore(password, this._required, this._recommended); } }); From 66f5bc4dbf840824614ef81183d207e2bdb90d68 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 31 Mar 2022 09:20:49 +0000 Subject: [PATCH 4/4] [IMP] portal: allow portal users to deactivate their accounts Purpose ======= Allow portal users to deactivate their accounts from the portal view. After the deactivation, they are redirected to the login page, so they can verify that they can not longer login with their credentials. We first archived the record and remove sensitive information (password, login, so he can not log in again with the same credentials). After the deactivation, we blacklist the email and the phone of the user, so we are sure that we never send him again email / SMS. Then, we create a to delete the user and the partner in a CRON because this operation can be heavy (write_uid, create_uid field on all models). Task-2629544 Part-of: odoo/odoo#78298 --- addons/auth_totp_portal/views/templates.xml | 2 +- addons/mail/models/res_users.py | 30 +++++++- addons/phone_validation/models/__init__.py | 1 + addons/phone_validation/models/res_users.py | 36 +++++++++ addons/portal/controllers/portal.py | 25 +++++++ addons/portal/static/src/js/portal.js | 24 ++++++ addons/portal/static/src/scss/portal.scss | 5 ++ addons/portal/views/portal_templates.xml | 69 ++++++++++++++++- addons/test_mail_full/tests/__init__.py | 1 + addons/test_mail_full/tests/test_res_users.py | 75 +++++++++++++++++++ odoo/addons/base/models/__init__.py | 1 + odoo/addons/base/models/res_users.py | 55 ++++++++++++++ odoo/addons/base/models/res_users_deletion.py | 66 ++++++++++++++++ odoo/addons/base/security/ir.model.access.csv | 2 + odoo/addons/base/tests/test_res_users.py | 73 ++++++++++++++++++ 15 files changed, 462 insertions(+), 3 deletions(-) create mode 100644 addons/phone_validation/models/res_users.py create mode 100644 addons/test_mail_full/tests/test_res_users.py create mode 100644 odoo/addons/base/models/res_users_deletion.py diff --git a/addons/auth_totp_portal/views/templates.xml b/addons/auth_totp_portal/views/templates.xml index 8bf1dc2db91..c7df5981326 100644 --- a/addons/auth_totp_portal/views/templates.xml +++ b/addons/auth_totp_portal/views/templates.xml @@ -1,6 +1,6 @@