@fishawack/lab-velocity 2.0.0-beta.40 → 2.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_Build/vue/modules/AuthModule/js/router.js +17 -36
- package/_Build/vue/modules/AuthModule/routes/PCompanies/columns.js +268 -0
- package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +172 -232
- package/_Build/vue/modules/AuthModule/routes/PUsers/columns.js +349 -0
- package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +143 -262
- package/_Build/vue/modules/resource/Children/create.vue +1 -1
- package/_Build/vue/modules/resource/Children/edit.vue +1 -1
- package/index.js +6 -0
- package/package.json +1 -1
- package/_Build/vue/modules/AuthModule/routes/PCompanies/form.vue +0 -205
- package/_Build/vue/modules/AuthModule/routes/PUsers/form.vue +0 -193
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { h } from "vue";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { ElMessageBox, ElNotification } from "element-plus";
|
|
5
|
+
|
|
6
|
+
import { columns, defaultResource } from "../../../resource/index.js";
|
|
7
|
+
import usersColumns, { detectedCompany } from "./columns.js";
|
|
8
|
+
|
|
1
9
|
import VelFormRole from "../../../../components/layout/FormRole.vue";
|
|
2
10
|
import VelButton from "../../../../components/basic/Button.vue";
|
|
3
|
-
import Chip from "../../../../components/layout/Chip.vue";
|
|
4
|
-
import Chips from "../../../../components/layout/Chips.vue";
|
|
5
11
|
import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
6
|
-
import component from "./form.vue";
|
|
7
|
-
import companyResource from "../PCompanies/resource.js";
|
|
8
|
-
import { defaultResource, meta } from "../../../resource/index.js";
|
|
9
|
-
|
|
10
|
-
import { ElMessageBox } from "element-plus";
|
|
11
|
-
import { ElNotification } from "element-plus";
|
|
12
|
-
import { h, resolveComponent } from "vue";
|
|
13
|
-
import axios from "axios";
|
|
14
12
|
|
|
15
13
|
function generatePassword(
|
|
16
14
|
length = 20,
|
|
@@ -43,280 +41,163 @@ export default [
|
|
|
43
41
|
edit: ({ $store }) => $store.getters.can("write users"),
|
|
44
42
|
delete: ({ $store }) => $store.getters.can("delete users"),
|
|
45
43
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
...merge(columns(usersColumns), {
|
|
45
|
+
form: {
|
|
46
|
+
fields: ({ model, method }) => ({
|
|
47
|
+
...columns(usersColumns).form.fields({ model }),
|
|
48
|
+
...(method === "post"
|
|
49
|
+
? {
|
|
50
|
+
notify_user: true,
|
|
51
|
+
force_password_change: true,
|
|
52
|
+
set_password: true,
|
|
53
|
+
password: null,
|
|
54
|
+
password_confirmation: null,
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
}),
|
|
58
|
+
async submit(props) {
|
|
59
|
+
const { model, form, $router, $store, method, resource } =
|
|
60
|
+
props;
|
|
50
61
|
|
|
51
|
-
|
|
62
|
+
const hold = form.data();
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
try {
|
|
65
|
+
form.populate(resource.form.preparation(props));
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
if (method === "post") {
|
|
68
|
+
const isSSOCompany =
|
|
69
|
+
!!detectedCompany.value?.sso_enabled;
|
|
58
70
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
if (!isSSOCompany && form.set_password) {
|
|
72
|
+
const password = generatePassword();
|
|
73
|
+
form.password = password;
|
|
74
|
+
form.password_confirmation = password;
|
|
75
|
+
}
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
let res = await form.post(`/api/users`);
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if (
|
|
80
|
+
!isSSOCompany &&
|
|
81
|
+
form.set_password &&
|
|
82
|
+
!form.notify_user
|
|
83
|
+
) {
|
|
84
|
+
ElMessageBox.alert(
|
|
85
|
+
`<p>The password below will not be shown again. Ensure you've taken a copy if you plan to send manually. <br><br><strong>Email</strong>: ${form.email}<br> <strong>Password</strong>: ${form.password}</p>`,
|
|
86
|
+
"User Created",
|
|
87
|
+
{
|
|
88
|
+
confirmButtonText: "Ok",
|
|
89
|
+
dangerouslyUseHTMLString: true,
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
.then(() => {
|
|
93
|
+
$router.replace({
|
|
94
|
+
name: "users.show",
|
|
95
|
+
params: {
|
|
96
|
+
[resource.id]: res.data.id,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
})
|
|
100
|
+
.catch(() => {});
|
|
101
|
+
} else {
|
|
102
|
+
ElNotification({
|
|
103
|
+
title: "Success",
|
|
104
|
+
message: isSSOCompany
|
|
105
|
+
? "SSO user pre-provisioned successfully"
|
|
106
|
+
: "User created a notified of their new account",
|
|
107
|
+
type: "success",
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
$router.replace({
|
|
111
|
+
name: "users.show",
|
|
112
|
+
params: {
|
|
113
|
+
[resource.id]: res.data.id,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
87
117
|
} else {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
118
|
+
let res = await form.patch(
|
|
119
|
+
`/api/users/${model.id}`,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (res.data.id === $store.state.auth.user.id) {
|
|
123
|
+
await $store.dispatch("getUser");
|
|
124
|
+
}
|
|
95
125
|
|
|
96
126
|
$router.replace({
|
|
97
127
|
name: "users.show",
|
|
98
|
-
params: {
|
|
128
|
+
params: {
|
|
129
|
+
[resource.id]: res.data.id,
|
|
130
|
+
},
|
|
99
131
|
});
|
|
100
132
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.log(e);
|
|
135
|
+
} finally {
|
|
136
|
+
if (
|
|
137
|
+
!form.successful ||
|
|
138
|
+
!form.__options.resetOnSuccess
|
|
139
|
+
) {
|
|
140
|
+
form.populate(hold);
|
|
107
141
|
}
|
|
108
|
-
|
|
109
|
-
$router.replace({
|
|
110
|
-
name: "users.show",
|
|
111
|
-
params: { [resource.id]: res.data.id },
|
|
112
|
-
});
|
|
113
142
|
}
|
|
114
|
-
} catch (e) {
|
|
115
|
-
console.log(e);
|
|
116
|
-
} finally {
|
|
117
|
-
if (!form.successful || !form.__options.resetOnSuccess) {
|
|
118
|
-
form.populate(hold);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
component,
|
|
123
|
-
fields: ({ model, method }) => ({
|
|
124
|
-
...{
|
|
125
|
-
name: model?.name ?? null,
|
|
126
|
-
email: model?.email ?? null,
|
|
127
|
-
roles: model?.overrides_roles_and_permissions
|
|
128
|
-
? model?.roles.map((val) => ({
|
|
129
|
-
label: val.label,
|
|
130
|
-
value: val.id,
|
|
131
|
-
}))
|
|
132
|
-
: [],
|
|
133
|
-
company_id: model?.company_id ?? null,
|
|
134
143
|
},
|
|
135
|
-
...(method === "post"
|
|
136
|
-
? {
|
|
137
|
-
notify_user: true,
|
|
138
|
-
force_password_change: true,
|
|
139
|
-
set_password: true,
|
|
140
|
-
password: null,
|
|
141
|
-
password_confirmation: null,
|
|
142
|
-
}
|
|
143
|
-
: {}),
|
|
144
|
-
}),
|
|
145
|
-
preparation: (props) => {
|
|
146
|
-
const data = props.form.data();
|
|
147
|
-
data.roles = data.roles.map((d) => d.value);
|
|
148
|
-
return data;
|
|
149
144
|
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
render: ({ model }) =>
|
|
164
|
-
model.company && model.company?.deleted_at
|
|
165
|
-
? h(
|
|
166
|
-
"span",
|
|
167
|
-
{ class: "vel-basic__error" },
|
|
168
|
-
model.company.name,
|
|
169
|
-
)
|
|
170
|
-
: h(resolveComponent("router-link"), {
|
|
171
|
-
class: "underline",
|
|
172
|
-
to: {
|
|
173
|
-
name: "companies.show",
|
|
174
|
-
params: {
|
|
175
|
-
[meta(...companyResource).id]:
|
|
176
|
-
model.company_id,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
text: model.company.name,
|
|
180
|
-
}),
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
key: "role",
|
|
184
|
-
render: ({ model }) =>
|
|
185
|
-
h(
|
|
186
|
-
!model.overrides_roles_and_permissions ||
|
|
187
|
-
model.roles.length === 1
|
|
188
|
-
? Chip
|
|
189
|
-
: Chips,
|
|
190
|
-
!model.overrides_roles_and_permissions
|
|
191
|
-
? {
|
|
192
|
-
name: "inherited",
|
|
193
|
-
label: "Inherited",
|
|
194
|
-
}
|
|
195
|
-
: model.roles.length === 1
|
|
196
|
-
? {
|
|
197
|
-
name: model.roles[0].name,
|
|
198
|
-
label: model.roles[0].label,
|
|
199
|
-
}
|
|
200
|
-
: { array: model.roles },
|
|
201
|
-
),
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
key: "verified",
|
|
205
|
-
label: "Verified",
|
|
206
|
-
render: ({ model }) =>
|
|
145
|
+
index: {
|
|
146
|
+
layout: [
|
|
147
|
+
...defaultResource.index.layout,
|
|
148
|
+
() =>
|
|
149
|
+
h(VelRoleLegend, {
|
|
150
|
+
class: "mt-5",
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
show: {
|
|
155
|
+
actions: [
|
|
156
|
+
({ model, $store, $root }) =>
|
|
157
|
+
$store.getters.can("impersonate users") &&
|
|
207
158
|
h(
|
|
208
|
-
|
|
159
|
+
VelButton,
|
|
209
160
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
),
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
description: {
|
|
226
|
-
structure: () => [
|
|
227
|
-
{
|
|
228
|
-
key: "email",
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
key: "company",
|
|
232
|
-
render: ({ model }) =>
|
|
233
|
-
model.company && model.company?.deleted_at
|
|
234
|
-
? h(
|
|
235
|
-
"span",
|
|
236
|
-
{ class: "vel-basic__error" },
|
|
237
|
-
model.company.name,
|
|
238
|
-
)
|
|
239
|
-
: h(resolveComponent("router-link"), {
|
|
240
|
-
class: "underline",
|
|
241
|
-
to: {
|
|
242
|
-
name: "companies.show",
|
|
243
|
-
params: {
|
|
244
|
-
[meta(...companyResource).id]:
|
|
245
|
-
model.company_id,
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
text: model.company.name,
|
|
249
|
-
}),
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
key: "email_verified_at",
|
|
253
|
-
label: "Email Verified",
|
|
254
|
-
render: ({ model }) =>
|
|
255
|
-
h(
|
|
256
|
-
"span",
|
|
257
|
-
{},
|
|
258
|
-
model.email_verified_at
|
|
259
|
-
? new Date(
|
|
260
|
-
model.email_verified_at,
|
|
261
|
-
).toLocaleString()
|
|
262
|
-
: "Not verified",
|
|
263
|
-
),
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
},
|
|
267
|
-
index: {
|
|
268
|
-
layout: [
|
|
269
|
-
...defaultResource.index.layout,
|
|
270
|
-
() =>
|
|
271
|
-
h(VelRoleLegend, {
|
|
272
|
-
class: "mt-5",
|
|
273
|
-
}),
|
|
274
|
-
],
|
|
275
|
-
},
|
|
276
|
-
show: {
|
|
277
|
-
actions: [
|
|
278
|
-
({ model, $store, $root }) =>
|
|
279
|
-
$store.getters.can("impersonate users") &&
|
|
280
|
-
h(
|
|
281
|
-
VelButton,
|
|
282
|
-
{
|
|
283
|
-
type: "danger",
|
|
284
|
-
async onClick() {
|
|
285
|
-
try {
|
|
286
|
-
const user = (
|
|
287
|
-
await axios.post(
|
|
288
|
-
`/api/users/impersonate`,
|
|
289
|
-
{
|
|
290
|
-
user_id: model.id,
|
|
291
|
-
},
|
|
292
|
-
)
|
|
293
|
-
).data.data;
|
|
161
|
+
type: "danger",
|
|
162
|
+
async onClick() {
|
|
163
|
+
try {
|
|
164
|
+
const user = (
|
|
165
|
+
await axios.post(
|
|
166
|
+
`/api/users/impersonate`,
|
|
167
|
+
{
|
|
168
|
+
user_id: model.id,
|
|
169
|
+
},
|
|
170
|
+
)
|
|
171
|
+
).data.data;
|
|
294
172
|
|
|
295
|
-
|
|
173
|
+
$store.commit("setUser", user);
|
|
296
174
|
|
|
297
|
-
|
|
298
|
-
|
|
175
|
+
if (!$store.getters.can("view admin")) {
|
|
176
|
+
window.location = `${$root.spaUrl}?authenticated=1`;
|
|
177
|
+
}
|
|
178
|
+
} catch (e) {
|
|
179
|
+
console.log(e);
|
|
299
180
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
"Impersonate",
|
|
184
|
+
),
|
|
185
|
+
...defaultResource.show.actions,
|
|
186
|
+
],
|
|
187
|
+
tabs: [
|
|
188
|
+
...defaultResource.show.tabs,
|
|
189
|
+
({ model }) => ({
|
|
190
|
+
label: "Access control",
|
|
191
|
+
component: h(VelFormRole, {
|
|
192
|
+
overrides: model.overrides_roles_and_permissions,
|
|
193
|
+
form: {
|
|
194
|
+
roles: model.roles.map((d) => d.id),
|
|
303
195
|
},
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
),
|
|
307
|
-
...defaultResource.show.actions,
|
|
308
|
-
],
|
|
309
|
-
tabs: [
|
|
310
|
-
...defaultResource.show.tabs,
|
|
311
|
-
({ model }) => ({
|
|
312
|
-
label: "Access control",
|
|
313
|
-
component: h(VelFormRole, {
|
|
314
|
-
overrides: model.overrides_roles_and_permissions,
|
|
315
|
-
form: { roles: model.roles.map((d) => d.id) },
|
|
316
|
-
readonly: true,
|
|
196
|
+
readonly: true,
|
|
197
|
+
}),
|
|
317
198
|
}),
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
321
202
|
},
|
|
322
203
|
];
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
if (this.resource.form.submit) {
|
|
52
52
|
await this.resource.form.submit(this);
|
|
53
53
|
} else {
|
|
54
|
-
const hold =
|
|
54
|
+
const hold = { ...this.form.data() };
|
|
55
55
|
|
|
56
56
|
try {
|
|
57
57
|
this.form.populate(this.resource.form.preparation(this));
|
|
@@ -76,7 +76,7 @@ export default {
|
|
|
76
76
|
if (this.resource.form.submit) {
|
|
77
77
|
await this.resource.form.submit(this);
|
|
78
78
|
} else {
|
|
79
|
-
const hold =
|
|
79
|
+
const hold = { ...this.form.data() };
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
82
|
this.form.populate(this.resource.form.preparation(this));
|
package/index.js
CHANGED
|
@@ -10,6 +10,12 @@ export const Auth = {
|
|
|
10
10
|
|
|
11
11
|
export { default as Resource } from "./_Build/vue/modules/resource/index.js";
|
|
12
12
|
|
|
13
|
+
export { default as UserResource } from "./_Build/vue/modules/AuthModule/routes/PUsers/resource.js";
|
|
14
|
+
export { default as UserColumns } from "./_Build/vue/modules/AuthModule/routes/PUsers/columns.js";
|
|
15
|
+
export { default as CompanyResource } from "./_Build/vue/modules/AuthModule/routes/PCompanies/resource.js";
|
|
16
|
+
export { default as CompanyColumns } from "./_Build/vue/modules/AuthModule/routes/PCompanies/columns.js";
|
|
17
|
+
export { default as TeamResource } from "./_Build/vue/modules/AuthModule/routes/PTeams/resource.js";
|
|
18
|
+
|
|
13
19
|
export { default as Button } from "./_Build/vue/components/basic/Button.vue";
|
|
14
20
|
export { default as Link } from "./_Build/vue/components/basic/link.vue";
|
|
15
21
|
|