Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions apps/settings/src/components/Users/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -640,40 +640,45 @@ export default {
*
* @param {string} displayName The display name
*/
updateDisplayName() {
async updateDisplayName() {
this.loading.displayName = true
this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'displayname',
value: this.editedDisplayName,
}).then(() => {
this.loading.displayName = false
try {
await this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'displayname',
value: this.editedDisplayName,
})

if (this.editedDisplayName === this.user.displayname) {
showSuccess(t('settings', 'Display name was successfully changed'))
}
})
} finally {
this.loading.displayName = false
}
},

/**
* Set user password
*
* @param {string} password The email address
*/
updatePassword() {
async updatePassword() {
this.loading.password = true
if (this.editedPassword.length === 0) {
showError(t('settings', "Password can't be empty"))
this.loading.password = false
} else {
this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'password',
value: this.editedPassword,
}).then(() => {
this.loading.password = false
try {
await this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'password',
value: this.editedPassword,
})
this.editedPassword = ''
showSuccess(t('settings', 'Password was successfully changed'))
})
} finally {
this.loading.password = false
}
}
},

Expand All @@ -682,23 +687,26 @@ export default {
*
* @param {string} mailAddress The email address
*/
updateEmail() {
async updateEmail() {
this.loading.mailAddress = true
if (this.editedMail === '') {
showError(t('settings', "Email can't be empty"))
this.loading.mailAddress = false
this.editedMail = this.user.email
} else {
this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'email',
value: this.editedMail,
}).then(() => {
this.loading.mailAddress = false
try {
await this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'email',
value: this.editedMail,
})

if (this.editedMail === this.user.email) {
showSuccess(t('settings', 'Email was successfully changed'))
}
})
} finally {
this.loading.mailAddress = false
}
}
},

Expand Down
27 changes: 16 additions & 11 deletions apps/settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,14 @@ const actions = {
* @param {string} userid User id
* @return {Promise}
*/
wipeUserDevices(context, userid) {
return api.requireAdmin().then((response) => {
return api.post(generateOcsUrl('cloud/users/{userid}/wipe', { userid }))
.catch((error) => { throw error })
}).catch((error) => context.commit('API_FAILURE', { userid, error }))
async wipeUserDevices(context, userid) {
try {
await api.requireAdmin()
return await api.post(generateOcsUrl('cloud/users/{userid}/wipe', { userid }))
} catch (error) {
context.commit('API_FAILURE', { userid, error })
return Promise.reject(new Error('Failed to wipe user devices'))
}
},

/**
Expand Down Expand Up @@ -730,7 +733,7 @@ const actions = {
* @param {string} options.value Value of the change
* @return {Promise}
*/
setUserData(context, { userid, key, value }) {
async setUserData(context, { userid, key, value }) {
const allowedEmpty = ['email', 'displayname', 'manager']
if (['email', 'language', 'quota', 'displayname', 'password', 'manager'].indexOf(key) !== -1) {
// We allow empty email or displayname
Expand All @@ -740,11 +743,13 @@ const actions = {
|| allowedEmpty.indexOf(key) !== -1
)
) {
return api.requireAdmin().then((response) => {
return api.put(generateOcsUrl('cloud/users/{userid}', { userid }), { key, value })
.then((response) => context.commit('setUserData', { userid, key, value }))
.catch((error) => { throw error })
}).catch((error) => context.commit('API_FAILURE', { userid, error }))
try {
await api.requireAdmin()
await api.put(generateOcsUrl('cloud/users/{userid}', { userid }), { key, value })
return context.commit('setUserData', { userid, key, value })
} catch (error) {
context.commit('API_FAILURE', { userid, error })
}
}
}
return Promise.reject(new Error('Invalid request data'))
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-users-3239.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-3239.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

Loading