Skip to content

Commit 017f475

Browse files
committed
random improvements
[ci skip]
1 parent 2a35ec9 commit 017f475

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
1,
4848
"unix"
4949
],
50+
"no-trailing-spaces": [
51+
1
52+
],
5053

5154
"semi": [
5255
1,

src/magister.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class Magister {
382382

383383
const options = this._options
384384
const schoolUrl = this.school.url
385-
const filteredName = schoolUrl.split('https://').join('')
385+
const filteredName = schoolUrl.replace('https://', '')
386386

387387
let authorizeUrl = 'https://accounts.magister.net/connect/authorize'
388388
authorizeUrl += `?client_id=M6-${filteredName}`
@@ -471,9 +471,8 @@ class Magister {
471471
.split('&access_token=')[1]
472472
.split('&')[0])
473473
.then(setToken)
474-
const accountData = await
475-
this.http.get(`${schoolUrl}/api/account`)
476-
.then(res => res.json())
474+
const accountData =
475+
await this.http.get(`${schoolUrl}/api/account`).then(res => res.json())
477476
const id = accountData.Persoon.Id
478477

479478
// REVIEW: do we want to make profileInfo a function?

src/profileSettings.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ class ProfileSettings extends MagisterThing {
1414

1515
/**
1616
* @type Boolean
17-
* @readonly
1817
*/
1918
this.redirectMagisterMessages = raw.EloBerichtenDoorsturen
2019
/**
2120
* @type String
22-
* @readonly
2321
*/
2422
this.emailAddress = raw.EmailAdres
2523
/**
2624
* @type String
27-
* @readonly
2825
*/
2926
this.mobileNumber = raw.Mobiel
3027
}
@@ -34,18 +31,17 @@ class ProfileSettings extends MagisterThing {
3431
* ProfileSettings instance.
3532
* @return {Promise<Error|undefined>}
3633
*/
37-
saveChanges() {
38-
const url = `${this._magister._personUrl}/profiel`
34+
async saveChanges() {
35+
await this._magister._privileges.needs('profiel', 'update')
3936

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())
4339
}
4440

4541
/**
46-
* Change the user password,
42+
* Change the user password,
4743
* seperate function because requires verification.
48-
*
44+
*
4945
* @param {String} changed
5046
* @param {String} [original] - Not required, defaults to password set on auth
5147
* @return {Promise}
@@ -55,14 +51,14 @@ class ProfileSettings extends MagisterThing {
5551
const schoolUrl = this._magister.school.url
5652

5753
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,
6056
}).then(res => res.json())
6157

6258
if (profile.isVerified) {
6359
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,
6662
'wachtwoordControle': original,
6763
}).then(res => res.status)
6864

0 commit comments

Comments
 (0)