Skip to content

Commit

Permalink
random improvements
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
lieuwex committed Nov 5, 2018
1 parent 2a35ec9 commit 017f475
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
1,
"unix"
],
"no-trailing-spaces": [
1
],

"semi": [
1,
Expand Down
7 changes: 3 additions & 4 deletions src/magister.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class Magister {

const options = this._options
const schoolUrl = this.school.url
const filteredName = schoolUrl.split('https://').join('')
const filteredName = schoolUrl.replace('https://', '')

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

// REVIEW: do we want to make profileInfo a function?
Expand Down
24 changes: 10 additions & 14 deletions src/profileSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ class ProfileSettings extends MagisterThing {

/**
* @type Boolean
* @readonly
*/
this.redirectMagisterMessages = raw.EloBerichtenDoorsturen
/**
* @type String
* @readonly
*/
this.emailAddress = raw.EmailAdres
/**
* @type String
* @readonly
*/
this.mobileNumber = raw.Mobiel
}
Expand All @@ -34,18 +31,17 @@ class ProfileSettings extends MagisterThing {
* ProfileSettings instance.
* @return {Promise<Error|undefined>}
*/
saveChanges() {
const url = `${this._magister._personUrl}/profiel`
async saveChanges() {
await this._magister._privileges.needs('profiel', 'update')

return this._magister._privileges.needs('profiel', 'update')
.then(() => this._magister.http.put(url, this._toMagister()))
.then(() => undefined)
const url = `${this._magister._personUrl}/profiel`
await this._magister.http.put(url, this._toMagister())
}

/**
* Change the user password,
* Change the user password,
* seperate function because requires verification.
*
*
* @param {String} changed
* @param {String} [original] - Not required, defaults to password set on auth
* @return {Promise}
Expand All @@ -55,14 +51,14 @@ class ProfileSettings extends MagisterThing {
const schoolUrl = this._magister.school.url

await this._magister._privileges.needs('wachtwoordwijzigen', 'update')
const profile = await this._magister.http.post(`${schoolUrl}/api/sessies/huidige/valideer`, {
'wachtwoord': original,
const profile = await this._magister.http.post(`${schoolUrl}/api/sessies/huidige/valideer`, {
'wachtwoord': original,
}).then(res => res.json())

if (profile.isVerified) {
const selfUrl = profile.links.account.href
const status = await this._magister.http.put(`${schoolUrl}/${selfUrl}/wachtwoord`, {
'wachtwoord': changed,
const status = await this._magister.http.put(`${schoolUrl}/${selfUrl}/wachtwoord`, {
'wachtwoord': changed,
'wachtwoordControle': original,
}).then(res => res.status)

Expand Down

0 comments on commit 017f475

Please sign in to comment.