blob: e75d8dfda38e66d2d1106c9b01adc8eba1ca0f3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
odoo.define('web.ChangePassword', function (require) {
"use strict";
/**
* This file defines a client action that opens in a dialog (target='new') and
* allows the user to change his password.
*/
var AbstractAction = require('web.AbstractAction');
var core = require('web.core');
var Dialog = require('web.Dialog');
var web_client = require('web.web_client');
var _t = core._t;
var ChangePassword = AbstractAction.extend({
template: "ChangePassword",
/**
* @fixme: weird interaction with the parent for the $buttons handling
*
* @override
* @returns {Promise}
*/
start: function () {
var self = this;
web_client.set_title(_t("Change Password"));
var $button = self.$('.oe_form_button');
$button.appendTo(this.getParent().$footer);
$button.eq(1).click(function () {
self.$el.parents('.modal').modal('hide');
});
$button.eq(0).click(function () {
self._rpc({
route: '/web/session/change_password',
params: {
fields: $('form[name=change_password_form]').serializeArray()
}
})
.then(function (result) {
if (result.error) {
self._display_error(result);
} else {
self.do_action('logout');
}
});
});
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* Displays the error in a dialog
*
* @private
* @param {Object} error
* @param {string} error.error
* @param {string} error.title
*/
_display_error: function (error) {
return new Dialog(this, {
size: 'medium',
title: error.title,
$content: $('<div>').html(error.error)
}).open();
},
});
core.action_registry.add("change_password", ChangePassword);
return ChangePassword;
});
|