From 28434749db4ef0d370cd545f02f5a3a4e7775530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 7 Nov 2023 18:08:43 +0100 Subject: [PATCH] Allow resetting forgotten password Closes #10629 --- sao/CHANGELOG | 1 + sao/src/session.js | 49 +++++++++++++++++++++++++++++++++- tryton/CHANGELOG | 1 + tryton/tryton/common/common.py | 31 ++++++++++++++++++--- tryton/tryton/rpc.py | 18 +++++++++++++ 5 files changed, 95 insertions(+), 5 deletions(-) diff --git a/sao/CHANGELOG b/sao/CHANGELOG index d28366f1b2..1c53037a99 100644 --- a/sao/CHANGELOG +++ b/sao/CHANGELOG @@ -1,3 +1,4 @@ +* Allow resetting forgotten password Version 7.0.0 - 2023-10-30 -------------------------- diff --git a/sao/src/session.js b/sao/src/session.js index 5f6380777a..ab2d667e4f 100644 --- a/sao/src/session.js +++ b/sao/src/session.js @@ -87,6 +87,23 @@ } return prm; }, + do_reset_password: function() { + if (!this.login) { + return jQuery.when(); + } + const args = { + 'id': 0, + 'method': 'common.db.reset_password', + 'params': [this.login, Sao.i18n.getlang()], + }; + return jQuery.ajax({ + 'contentType': 'application/json', + 'data': JSON.stringify(args), + 'dataType': 'json', + 'url': '/' + this.database + '/', + 'type': 'post', + }); + }, reload_context: function() { var args = { 'method': 'model.res.user.get_preferences', @@ -518,7 +535,37 @@ return Sao.common.ask.run(message, name); }, get_password: function(message, name) { - return Sao.common.ask.run(message, name, false); + const session = this.session; + const AskPasswordDialog = Sao.class_(Sao.common.AskDialog, { + build_dialog: function(question, name, visibility, prm) { + const dialog = AskPasswordDialog._super.build_dialog.call( + this, question, name, visibility, prm); + jQuery('