From 66f5bc4dbf840824614ef81183d207e2bdb90d68 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 31 Mar 2022 09:20:49 +0000 Subject: [PATCH] [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 @@