|
1 | 1 | import Controller from '@ember/controller';
|
| 2 | +import { action } from '@ember/object'; |
2 | 3 |
|
3 |
| -export default Controller.extend({ |
4 |
| - actions: { |
5 |
| - changePassword(passwordData) { |
6 |
| - this.set('isLoading', true); |
7 |
| - let payload = { |
8 |
| - 'data': { |
9 |
| - 'old-password' : passwordData.passwordCurrent, |
10 |
| - 'new-password' : passwordData.passwordNew |
11 |
| - } |
12 |
| - }; |
13 |
| - this.loader |
14 |
| - .post('/auth/change-password', payload) |
15 |
| - .then(() => { |
16 |
| - this.notify.success(this.l10n.t('Password updated successfully'), |
| 4 | +export default class extends Controller { |
| 5 | + |
| 6 | + @action |
| 7 | + changePassword(passwordData) { |
| 8 | + this.set('isLoading', true); |
| 9 | + let payload = { |
| 10 | + 'data': { |
| 11 | + 'old-password' : passwordData.passwordCurrent, |
| 12 | + 'new-password' : passwordData.passwordNew |
| 13 | + } |
| 14 | + }; |
| 15 | + this.loader |
| 16 | + .post('/auth/change-password', payload) |
| 17 | + .then(() => { |
| 18 | + this.notify.success(this.l10n.t('Password updated successfully'), |
| 19 | + { |
| 20 | + id: 'pass_upd_succ' |
| 21 | + }); |
| 22 | + }) |
| 23 | + .catch(error => { |
| 24 | + if (error.errors) { |
| 25 | + this.notify.error(this.l10n.t(`${error.errors[0].detail}`), |
| 26 | + { |
| 27 | + id: 'err_pass_ser' |
| 28 | + }); |
| 29 | + } else { |
| 30 | + this.notify.error(this.l10n.t('Unexpected error. Password did not change.'), |
17 | 31 | {
|
18 |
| - id: 'pass_upd_succ' |
| 32 | + id: 'err_unex_pass' |
19 | 33 | });
|
20 |
| - }) |
21 |
| - .catch(error => { |
22 |
| - if (error.errors) { |
23 |
| - this.notify.error(this.l10n.t(`${error.errors[0].detail}`), |
24 |
| - { |
25 |
| - id: 'err_pass_ser' |
26 |
| - }); |
27 |
| - } else { |
28 |
| - this.notify.error(this.l10n.t('Unexpected error. Password did not change.'), |
29 |
| - { |
30 |
| - id: 'err_unex_pass' |
31 |
| - }); |
32 |
| - } |
33 |
| - }) |
34 |
| - .finally(() => { |
35 |
| - this.set('isLoading', false); |
36 |
| - this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' }); |
37 |
| - }); |
38 |
| - } |
| 34 | + } |
| 35 | + }) |
| 36 | + .finally(() => { |
| 37 | + this.set('isLoading', false); |
| 38 | + this.setProperties({ 'passwordCurrent': '', 'passwordNew': '', 'passwordRepeat': '' }); |
| 39 | + }); |
39 | 40 | }
|
40 |
| -}); |
| 41 | +} |
| 42 | + |
0 commit comments