Mercurial > gemma
annotate client/src/store/usermanagement.js @ 5583:c1bd5f8eaf9a surveysperbottleneckid
AvailableFairwayDepthDialogue: set objnam for print is okay
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 14 Feb 2022 12:06:48 +0100 |
parents | 29af073c824d |
children |
rev | line source |
---|---|
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
3 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
6 * |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
10 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
11 * Author(s): |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
1363 | 13 * Markus Kottländer <markus@intevation.de> |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
14 */ |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
15 |
2947
a6eea3002e6e
client: cleanup import paths
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1363
diff
changeset
|
16 import { HTTP } from "@/lib/http"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
18 // initial state |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
19 const init = () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
20 return { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
21 users: null, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
22 currentUser: null, |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
23 userDetailsVisible: false |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
24 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
25 }; |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
26 |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 const newUser = () => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 return { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 user: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 email: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 country: null, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 role: null, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 isNew: true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 password: "", |
5508
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
35 roleLabel: "", |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
36 active: true |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
38 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
39 |
1114
8d12056d602a
shortened store file imports
Markus Kottlaender <markus@intevation.de>
parents:
1096
diff
changeset
|
40 export default { |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
41 init, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
42 namespaced: true, |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
43 state: init(), |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
44 getters: { |
3506
e2ed741545e1
import_overview: added country column
Thomas Junk <thomas.junk@intevation.de>
parents:
2947
diff
changeset
|
45 userCountries: state => { |
3670
2c0170be6cf0
usermanagement: return an empty list of user countries in case the user is logged out and the object is not present
Thomas Junk <thomas.junk@intevation.de>
parents:
3508
diff
changeset
|
46 if (!state.users) return []; |
3506
e2ed741545e1
import_overview: added country column
Thomas Junk <thomas.junk@intevation.de>
parents:
2947
diff
changeset
|
47 return state.users.reduce((o, n) => { |
3508
081182dfcc35
import_overview: country for sys_admin = global
Thomas Junk <thomas.junk@intevation.de>
parents:
3506
diff
changeset
|
48 o[n.user] = n.role !== "sys_admin" ? n.country : "global"; |
3506
e2ed741545e1
import_overview: added country column
Thomas Junk <thomas.junk@intevation.de>
parents:
2947
diff
changeset
|
49 return o; |
e2ed741545e1
import_overview: added country column
Thomas Junk <thomas.junk@intevation.de>
parents:
2947
diff
changeset
|
50 }, {}); |
e2ed741545e1
import_overview: added country column
Thomas Junk <thomas.junk@intevation.de>
parents:
2947
diff
changeset
|
51 }, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 isUserDetailsVisible: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
53 return state.userDetailsVisible; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
54 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
55 currentUser: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 return state.currentUser; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
58 users: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 return state.users; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 getUserByName: state => name => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 return state.users.find(user => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
63 return user.user === name; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
66 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
67 mutations: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
68 setUserDetailsInvisible: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
69 state.userDetailsVisible = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
70 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
71 setUserDetailsVisible: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
72 state.userDetailsVisible = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
74 usersLoaded: (state, data) => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
75 const resolveLabel = x => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
76 const labels = { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 waterway_user: "Waterway User", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
78 waterway_admin: "Waterway Administrator", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
79 sys_admin: "System Admininistrator" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
80 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
81 return labels[x]; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
82 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 let users = data.users.map(u => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 u["roleLabel"] = resolveLabel(u["role"]); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 return u; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 state.users = users; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 setCurrentUser: (state, data) => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
90 state.currentUser = data; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 state.userDetailsVisible = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 clearCurrentUser: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
94 state.currentUser = newUser(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
96 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 actions: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 deleteUser({ commit }, data) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 const { name } = data; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 return new Promise((resolve, reject) => { |
4430 | 101 HTTP.delete("/users/" + encodeURIComponent(`${name}`), { |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 .then(response => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 commit("clearCurrentUser"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 commit("setUserDetailsInvisible"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 resolve(response); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 reject(error); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 saveCurrentUser({ commit }, data) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 const { path, user } = data; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 if (user.isNew) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
117 return new Promise((resolve, reject) => { |
4430 | 118 HTTP.post("/users", user, { |
119 headers: { | |
120 "X-Gemma-Auth": localStorage.getItem("token") | |
121 } | |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 .then(response => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 commit("setUserDetailsInvisible"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
125 commit("clearCurrentUser"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
126 resolve(response); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 reject(error); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 } else { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 return new Promise((resolve, reject) => { |
5508
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
134 // Reactivate User |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
135 if (!user.active) { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
136 HTTP.patch( |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
137 "/users/" + path, |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
138 { active: true, email: user.email }, |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
139 { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
140 headers: { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
141 "X-Gemma-Auth": localStorage.getItem("token") |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
142 } |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
143 } |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
144 ) |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
145 .then(response => { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
146 commit("setUserDetailsInvisible"); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
147 commit("clearCurrentUser"); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
148 resolve(response); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
149 }) |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
150 .catch(error => { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
151 reject(error); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
152 }); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
153 } else { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
154 HTTP.put("/users/" + path, user, { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
155 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
156 }) |
5508
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
157 .then(response => { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
158 commit("setUserDetailsInvisible"); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
159 commit("clearCurrentUser"); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
160 resolve(response); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
161 }) |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
162 .catch(error => { |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
163 reject(error); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
164 }); |
29af073c824d
Client: Implement reactivating of user
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4430
diff
changeset
|
165 } |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
166 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
167 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
168 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
169 loadUsers({ commit }) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
170 return new Promise((resolve, reject) => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
171 HTTP.get("/users", { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
172 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
173 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
174 .then(response => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
175 commit("usersLoaded", response.data); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
176 resolve(response); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
177 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
178 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
179 reject(error); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
180 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
181 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
182 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
183 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
184 }; |