Mercurial > gemma
changeset 5508:29af073c824d deactivate-users
Client: Implement reactivating of user
* Add HTTP request to reactivate a deactivated user
* This is done from the user's edit-dialog while typing an email for this user is necessary to complete this process.
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Thu, 23 Sep 2021 17:33:07 +0200 |
parents | 279900b28b1b |
children | 36cbf14b878a |
files | client/src/components/usermanagement/Userdetail.vue client/src/store/usermanagement.js |
diffstat | 2 files changed, 42 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/usermanagement/Userdetail.vue Thu Sep 23 14:47:36 2021 +0200 +++ b/client/src/components/usermanagement/Userdetail.vue Thu Sep 23 17:33:07 2021 +0200 @@ -131,7 +131,9 @@ :disabled="submitted" class="shadow-sm btn btn-info submit-button" > - <translate>Save</translate> + <span>{{ + currentUser.active ? $gettext("Save") : $gettext("Reactivate") + }}</span> </button> </div> </form> @@ -245,6 +247,9 @@ }, mounted() { this.currentUser = { ...this.user }; + if (!this.currentUser.active) { + this.currentUser.email = ""; + } this.path = this.user.name; }, watch: { @@ -253,6 +258,9 @@ }, user() { this.currentUser = { ...this.user }; + if (!this.currentUser.active) { + this.currentUser.email = ""; + } this.path = this.user.name; this.clearPassword(); this.clearErrors();
--- a/client/src/store/usermanagement.js Thu Sep 23 14:47:36 2021 +0200 +++ b/client/src/store/usermanagement.js Thu Sep 23 17:33:07 2021 +0200 @@ -32,7 +32,8 @@ role: null, isNew: true, password: "", - roleLabel: "" + roleLabel: "", + active: true }; }; @@ -130,17 +131,38 @@ }); } else { return new Promise((resolve, reject) => { - HTTP.put("/users/" + path, user, { - headers: { "X-Gemma-Auth": localStorage.getItem("token") } - }) - .then(response => { - commit("setUserDetailsInvisible"); - commit("clearCurrentUser"); - resolve(response); + // Reactivate User + if (!user.active) { + HTTP.patch( + "/users/" + path, + { active: true, email: user.email }, + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + } + ) + .then(response => { + commit("setUserDetailsInvisible"); + commit("clearCurrentUser"); + resolve(response); + }) + .catch(error => { + reject(error); + }); + } else { + HTTP.put("/users/" + path, user, { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) - .catch(error => { - reject(error); - }); + .then(response => { + commit("setUserDetailsInvisible"); + commit("clearCurrentUser"); + resolve(response); + }) + .catch(error => { + reject(error); + }); + } }); } },