@@ -14,17 +14,14 @@ class ProfileSettings extends MagisterThing {
14
14
15
15
/**
16
16
* @type Boolean
17
- * @readonly
18
17
*/
19
18
this . redirectMagisterMessages = raw . EloBerichtenDoorsturen
20
19
/**
21
20
* @type String
22
- * @readonly
23
21
*/
24
22
this . emailAddress = raw . EmailAdres
25
23
/**
26
24
* @type String
27
- * @readonly
28
25
*/
29
26
this . mobileNumber = raw . Mobiel
30
27
}
@@ -34,18 +31,17 @@ class ProfileSettings extends MagisterThing {
34
31
* ProfileSettings instance.
35
32
* @return {Promise<Error|undefined> }
36
33
*/
37
- saveChanges ( ) {
38
- const url = ` ${ this . _magister . _personUrl } / profiel`
34
+ async saveChanges ( ) {
35
+ await this . _magister . _privileges . needs ( ' profiel' , 'update' )
39
36
40
- return this . _magister . _privileges . needs ( 'profiel' , 'update' )
41
- . then ( ( ) => this . _magister . http . put ( url , this . _toMagister ( ) ) )
42
- . then ( ( ) => undefined )
37
+ const url = `${ this . _magister . _personUrl } /profiel`
38
+ await this . _magister . http . put ( url , this . _toMagister ( ) )
43
39
}
44
40
45
41
/**
46
- * Change the user password,
42
+ * Change the user password,
47
43
* seperate function because requires verification.
48
- *
44
+ *
49
45
* @param {String } changed
50
46
* @param {String } [original] - Not required, defaults to password set on auth
51
47
* @return {Promise }
@@ -55,14 +51,14 @@ class ProfileSettings extends MagisterThing {
55
51
const schoolUrl = this . _magister . school . url
56
52
57
53
await this . _magister . _privileges . needs ( 'wachtwoordwijzigen' , 'update' )
58
- const profile = await this . _magister . http . post ( `${ schoolUrl } /api/sessies/huidige/valideer` , {
59
- 'wachtwoord' : original ,
54
+ const profile = await this . _magister . http . post ( `${ schoolUrl } /api/sessies/huidige/valideer` , {
55
+ 'wachtwoord' : original ,
60
56
} ) . then ( res => res . json ( ) )
61
57
62
58
if ( profile . isVerified ) {
63
59
const selfUrl = profile . links . account . href
64
- const status = await this . _magister . http . put ( `${ schoolUrl } /${ selfUrl } /wachtwoord` , {
65
- 'wachtwoord' : changed ,
60
+ const status = await this . _magister . http . put ( `${ schoolUrl } /${ selfUrl } /wachtwoord` , {
61
+ 'wachtwoord' : changed ,
66
62
'wachtwoordControle' : original ,
67
63
} ) . then ( res => res . status )
68
64
0 commit comments