@fishawack/lab-velocity 2.0.0-beta.4 → 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.
Files changed (110) hide show
  1. package/README.md +441 -37
  2. package/_Build/vue/components/basic/Button.vue +1 -1
  3. package/_Build/vue/components/form/Checkbox.vue +10 -0
  4. package/_Build/vue/components/form/Select.vue +223 -33
  5. package/_Build/vue/components/form/Spinner.vue +5 -0
  6. package/_Build/vue/components/layout/Alert.vue +5 -5
  7. package/_Build/vue/components/layout/Audit.vue +75 -0
  8. package/_Build/vue/{modules/AuthModule/components/VBreadcrumbs.vue → components/layout/Breadcrumbs.vue} +4 -4
  9. package/_Build/vue/{modules/AuthModule/components → components/layout}/Chips.vue +2 -2
  10. package/_Build/vue/components/layout/Footer.vue +11 -10
  11. package/_Build/vue/{modules/AuthModule/components/VFormFooter.vue → components/layout/FormFooter.vue} +13 -7
  12. package/_Build/vue/{modules/AuthModule/components → components/layout}/FormRole.vue +10 -8
  13. package/_Build/vue/components/layout/Layout.vue +76 -0
  14. package/_Build/vue/components/layout/Navigation.vue +77 -0
  15. package/_Build/vue/{modules/AuthModule/components/VPageHeader.vue → components/layout/PageHeader.vue} +7 -2
  16. package/_Build/vue/components/layout/SideBar.vue +26 -0
  17. package/_Build/vue/{modules/AuthModule/components/VTable.vue → components/layout/Table.vue} +32 -16
  18. package/_Build/vue/{modules/AuthModule/components/VTableSorter.vue → components/layout/TableSorter.vue} +68 -43
  19. package/_Build/vue/components/layout/pageTitle.vue +1 -1
  20. package/_Build/vue/components/navigation/MenuItem.vue +7 -2
  21. package/_Build/vue/components/navigation/MenuItemGroup.vue +7 -2
  22. package/_Build/vue/modules/AuthModule/js/axios.js +19 -0
  23. package/_Build/vue/modules/AuthModule/js/router.js +24 -89
  24. package/_Build/vue/modules/AuthModule/js/store.js +15 -6
  25. package/_Build/vue/modules/AuthModule/routes/PCompanies/columns.js +268 -0
  26. package/_Build/vue/modules/AuthModule/routes/PCompanies/resource.js +213 -0
  27. package/_Build/vue/modules/AuthModule/routes/PTeams/resource.js +334 -0
  28. package/_Build/vue/modules/AuthModule/routes/PUsers/columns.js +349 -0
  29. package/_Build/vue/modules/AuthModule/routes/PUsers/resource.js +203 -0
  30. package/_Build/vue/modules/AuthModule/routes/account-exists.vue +2 -2
  31. package/_Build/vue/modules/AuthModule/routes/change-password.vue +23 -24
  32. package/_Build/vue/modules/AuthModule/routes/container.vue +2 -11
  33. package/_Build/vue/modules/AuthModule/routes/expired-reset.vue +4 -4
  34. package/_Build/vue/modules/AuthModule/routes/expired-verification.vue +9 -8
  35. package/_Build/vue/modules/AuthModule/routes/force-reset.vue +39 -50
  36. package/_Build/vue/modules/AuthModule/routes/forgot.vue +4 -4
  37. package/_Build/vue/modules/AuthModule/routes/login.vue +7 -11
  38. package/_Build/vue/modules/AuthModule/routes/logincallback.vue +1 -3
  39. package/_Build/vue/modules/AuthModule/routes/loginsso.vue +7 -9
  40. package/_Build/vue/modules/AuthModule/routes/logout.vue +1 -3
  41. package/_Build/vue/modules/AuthModule/routes/logoutheadless.vue +1 -3
  42. package/_Build/vue/modules/AuthModule/routes/register.vue +19 -21
  43. package/_Build/vue/modules/AuthModule/routes/reset.vue +14 -13
  44. package/_Build/vue/modules/AuthModule/routes/success-forgot.vue +8 -7
  45. package/_Build/vue/modules/AuthModule/routes/success-reset.vue +2 -2
  46. package/_Build/vue/modules/AuthModule/routes/success-verify.vue +1 -3
  47. package/_Build/vue/modules/AuthModule/routes/verify.vue +11 -14
  48. package/_Build/vue/modules/resource/Children/create.vue +81 -0
  49. package/_Build/vue/modules/resource/Children/edit.vue +106 -0
  50. package/_Build/vue/modules/resource/Children/index.vue +42 -0
  51. package/_Build/vue/modules/resource/Children/partials/form.vue +61 -0
  52. package/_Build/vue/modules/resource/Children/show.vue +144 -0
  53. package/_Build/vue/modules/resource/index.js +545 -0
  54. package/_Build/vue/modules/resource/parent.vue +63 -0
  55. package/_base.scss +0 -1
  56. package/_defaults.scss +2 -13
  57. package/_variables.scss +9 -4
  58. package/components/_alert.scss +5 -0
  59. package/components/_auth.scss +163 -0
  60. package/components/_basic.scss +55 -0
  61. package/components/_breadcrumbs.scss +39 -0
  62. package/components/_button.scss +304 -0
  63. package/components/_cascader.scss +12 -0
  64. package/components/_checkbox.scss +41 -0
  65. package/components/_chip.scss +24 -0
  66. package/components/_collapse.scss +24 -0
  67. package/components/_datepicker.scss +53 -0
  68. package/components/_descriptions.scss +2 -0
  69. package/components/_footer.scss +47 -0
  70. package/components/_form.scss +24 -0
  71. package/components/_header.scss +30 -0
  72. package/components/_icon.scss +25 -0
  73. package/components/_inputNumber.scss +22 -0
  74. package/components/_layout.scss +56 -0
  75. package/components/_link.scss +44 -0
  76. package/components/_loader.scss +43 -0
  77. package/components/_menu.scss +112 -0
  78. package/components/_modal.scss +24 -0
  79. package/components/_pageTitle.scss +8 -0
  80. package/components/_permissionLegend.scss +18 -0
  81. package/components/_select.scss +29 -0
  82. package/components/_sidebar.scss +41 -0
  83. package/components/_switch.scss +14 -0
  84. package/components/_table.scss +20 -0
  85. package/components/_tooltip.scss +4 -0
  86. package/components/_typography.scss +162 -0
  87. package/components/_upload.scss +15 -0
  88. package/components/_wysiwyg.scss +7 -0
  89. package/components/_wysiwyg2.scss +142 -0
  90. package/index.js +16 -1
  91. package/package.json +5 -3
  92. package/vendor.scss +0 -1
  93. package/_Build/vue/components/layout/sideBar.vue +0 -25
  94. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/Upload/upload.vue +0 -251
  95. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/create.vue +0 -62
  96. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/edit.vue +0 -98
  97. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/index.vue +0 -90
  98. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/partials/form.vue +0 -173
  99. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/Children/show.vue +0 -262
  100. package/_Build/vue/modules/AuthModule/adminRoutes/PCompanies/parent.vue +0 -36
  101. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/create.vue +0 -112
  102. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/edit.vue +0 -103
  103. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/index.vue +0 -112
  104. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/partials/form.vue +0 -169
  105. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/Children/show.vue +0 -120
  106. package/_Build/vue/modules/AuthModule/adminRoutes/PUsers/parent.vue +0 -36
  107. /package/_Build/vue/{modules/AuthModule/components → components/layout}/AuthModal.vue +0 -0
  108. /package/_Build/vue/{modules/AuthModule/components → components/layout}/Chip.vue +0 -0
  109. /package/_Build/vue/{modules/AuthModule/components/VPasswordValidation.vue → components/layout/PasswordValidation.vue} +0 -0
  110. /package/_Build/vue/{modules/AuthModule/components/VRoleLegend.vue → components/layout/RoleLegend.vue} +0 -0
@@ -0,0 +1,203 @@
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
+
9
+ import VelFormRole from "../../../../components/layout/FormRole.vue";
10
+ import VelButton from "../../../../components/basic/Button.vue";
11
+ import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
12
+
13
+ function generatePassword(
14
+ length = 20,
15
+ characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$",
16
+ ) {
17
+ return (
18
+ Array.from(crypto.getRandomValues(new Uint32Array(length)))
19
+ .map((x) => characters[x % characters.length])
20
+ .join("") + Math.floor(Math.random() * 10)
21
+ );
22
+ }
23
+
24
+ export default [
25
+ "users",
26
+ {
27
+ api: {
28
+ params: {
29
+ index: ({ $route }) => ({
30
+ include: "company",
31
+ "filter[withTrashed]": $route.query.trashed,
32
+ }),
33
+ show: () => ({ include: "company" }),
34
+ },
35
+ },
36
+ searchable: {
37
+ value: "email",
38
+ },
39
+ permissions: {
40
+ create: ({ $store }) => $store.getters.can("write users"),
41
+ edit: ({ $store }) => $store.getters.can("write users"),
42
+ delete: ({ $store }) => $store.getters.can("delete users"),
43
+ },
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;
61
+
62
+ const hold = form.data();
63
+
64
+ try {
65
+ form.populate(resource.form.preparation(props));
66
+
67
+ if (method === "post") {
68
+ const isSSOCompany =
69
+ !!detectedCompany.value?.sso_enabled;
70
+
71
+ if (!isSSOCompany && form.set_password) {
72
+ const password = generatePassword();
73
+ form.password = password;
74
+ form.password_confirmation = password;
75
+ }
76
+
77
+ let res = await form.post(`/api/users`);
78
+
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
+ }
117
+ } else {
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
+ }
125
+
126
+ $router.replace({
127
+ name: "users.show",
128
+ params: {
129
+ [resource.id]: res.data.id,
130
+ },
131
+ });
132
+ }
133
+ } catch (e) {
134
+ console.log(e);
135
+ } finally {
136
+ if (
137
+ !form.successful ||
138
+ !form.__options.resetOnSuccess
139
+ ) {
140
+ form.populate(hold);
141
+ }
142
+ }
143
+ },
144
+ },
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") &&
158
+ h(
159
+ VelButton,
160
+ {
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;
172
+
173
+ $store.commit("setUser", user);
174
+
175
+ if (!$store.getters.can("view admin")) {
176
+ window.location = `${$root.spaUrl}?authenticated=1`;
177
+ }
178
+ } catch (e) {
179
+ console.log(e);
180
+ }
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),
195
+ },
196
+ readonly: true,
197
+ }),
198
+ }),
199
+ ],
200
+ },
201
+ }),
202
+ },
203
+ ];
@@ -3,10 +3,10 @@
3
3
  <section id="resetPasswordForm">
4
4
  <h1 class="h2">Account already exists</h1>
5
5
 
6
- <p class="mt AM-mb-0 color-21">
6
+ <p class="mt mb-0 color-21">
7
7
  <strong class="">Company: {{ $route.query.company }}</strong>
8
8
  </p>
9
- <p class="AM-mt-0.5">Your company already has an active account.</p>
9
+ <p class="mt-0.5">Your company already has an active account.</p>
10
10
 
11
11
  <elButton
12
12
  tag="router-link"
@@ -7,13 +7,13 @@
7
7
  />
8
8
  <form class="form" @submit.prevent="submit">
9
9
  <div v-if="!form.successful">
10
- <p class="AM-mt-2 AM-mb-0">
10
+ <p class="mt-2 mb-0">
11
11
  Please complete the fields below to change your
12
12
  password.
13
13
  </p>
14
14
 
15
15
  <el-input
16
- class="AM-mt-3"
16
+ class="mt-3"
17
17
  label="Current password"
18
18
  placeholder="Enter your current password"
19
19
  name="current_password"
@@ -25,7 +25,7 @@
25
25
  />
26
26
  <el-input
27
27
  v-model="form.password"
28
- class="AM-mt-2 AM-mb-2"
28
+ class="mt-2 mb-2"
29
29
  label="New Password"
30
30
  placeholder="Enter your new password"
31
31
  name="password"
@@ -36,11 +36,11 @@
36
36
  :password="true"
37
37
  />
38
38
 
39
- <VPasswordValidation
39
+ <VelPasswordValidation
40
40
  :password="form.password"
41
41
  @passwordValid="updatePasswordValidity"
42
42
  />
43
- <div class="flex AM-mt-3">
43
+ <div class="flex mt-3">
44
44
  <elButton
45
45
  native-type="submit"
46
46
  class=""
@@ -66,7 +66,11 @@
66
66
  >Email: {{ $store.state.auth?.user?.email }}</strong
67
67
  >
68
68
  <p v-text="`Your password has been updated.`" />
69
- <elButton class="" type="secondary" @click="handleButton">
69
+ <elButton
70
+ tag="router-link"
71
+ type="primary"
72
+ :to="{ name: $store.state.auth.redirect }"
73
+ >
70
74
  <span v-text="'Continue'" />
71
75
  </elButton>
72
76
  </div>
@@ -79,6 +83,14 @@
79
83
  import Form from "form-backend-validation";
80
84
 
81
85
  export default {
86
+ components: {
87
+ VelPasswordValidation:
88
+ require("../../../components/layout/PasswordValidation.vue")
89
+ .default,
90
+ elInput: require("../../../components/form/basic.vue").default,
91
+ elButton: require("../../../components/basic/Button.vue").default,
92
+ },
93
+
82
94
  data() {
83
95
  return {
84
96
  form: new Form(
@@ -94,9 +106,7 @@ export default {
94
106
  },
95
107
 
96
108
  mounted() {
97
- this.$store.dispatch("getUser", {
98
- errors: this.$root.errors,
99
- });
109
+ this.$store.dispatch("getUser");
100
110
  },
101
111
 
102
112
  methods: {
@@ -107,7 +117,7 @@ export default {
107
117
  await this.form.put("/user/password");
108
118
  await this.login();
109
119
  } catch (e) {
110
- this.$root.errors(e);
120
+ console.log(e);
111
121
  } finally {
112
122
  this.loading = false;
113
123
  }
@@ -120,15 +130,13 @@ export default {
120
130
 
121
131
  if (res["logged-in"]) {
122
132
  try {
123
- await this.$store.dispatch("logout", {
124
- // errors: this.$root.errors,
125
- });
133
+ await this.$store.dispatch("logout");
126
134
  } catch (e) {}
127
135
 
128
136
  await this.form.post("/login");
129
137
  }
130
138
  } catch (e) {
131
- this.$root.errors(e);
139
+ console.log(e);
132
140
  } finally {
133
141
  this.loading = false;
134
142
  this.postLogin();
@@ -143,9 +151,7 @@ export default {
143
151
  },
144
152
 
145
153
  async postLogin() {
146
- const { data: user } = await this.$store.dispatch("getUser", {
147
- errors: this.$root.errors,
148
- });
154
+ const { data: user } = await this.$store.dispatch("getUser");
149
155
  },
150
156
  },
151
157
 
@@ -154,12 +160,5 @@ export default {
154
160
  title: "Reset Password",
155
161
  };
156
162
  },
157
-
158
- components: {
159
- VPasswordValidation: require("./../components/VPasswordValidation.vue")
160
- .default,
161
- elInput: require("../../../components/form/basic.vue").default,
162
- elButton: require("../../../components/basic/Button.vue").default,
163
- },
164
163
  };
165
164
  </script>
@@ -5,7 +5,7 @@
5
5
  <router-link to="/" class="logo" aria-label="Go to home page">
6
6
  <GSvg
7
7
  class="AuthModule__logo"
8
- :name="logoName"
8
+ :name="$store.state.auth.logo"
9
9
  embed
10
10
  asis
11
11
  role="presentation"
@@ -21,14 +21,5 @@
21
21
  </template>
22
22
 
23
23
  <script>
24
- export default {
25
- mounted() {},
26
- data() {
27
- return {
28
- logoName: process.env.HYDRATE_LOGO,
29
- };
30
- },
31
-
32
- components: {},
33
- };
24
+ export default {};
34
25
  </script>
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <h1 class="h2 h2--small">Sorry, your password reset has expired</h1>
3
3
 
4
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
4
+ <p class="mt-2 mb-0 color-highlight">
5
5
  <strong class="">Email: {{ form?.email }}</strong>
6
6
  </p>
7
- <p class="AM-mt-0.5">
7
+ <p class="mt-0.5">
8
8
  For security, password reset requests are only
9
9
  <strong>active for 1&nbsp;hour</strong>. If you still want to reset your
10
10
  password, please request a new password reset-link.
@@ -31,7 +31,7 @@
31
31
  Request new reset-link
32
32
  </elButton>
33
33
 
34
- <p class="disclaimer AM-mt-3">
34
+ <p class="disclaimer mt-3">
35
35
  <router-link class="color-1 underline" :to="{ name: 'auth.login' }">
36
36
  Back to Sign in
37
37
  </router-link>
@@ -66,7 +66,7 @@ export default {
66
66
  query: { email: this.form.email },
67
67
  });
68
68
  } catch (e) {
69
- this.$root.errors(e);
69
+ console.log(e);
70
70
  }
71
71
  },
72
72
  },
@@ -2,16 +2,16 @@
2
2
  <h1 class="h2 h2--small">Verification link expired</h1>
3
3
 
4
4
  <form class="form" @submit.prevent="submit">
5
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
5
+ <p class="mt-2 mb-0 color-highlight">
6
6
  <strong class="">Email: {{ form?.email }}</strong>
7
7
  </p>
8
- <p class="AM-mt-0.5">
8
+ <p class="mt-0.5">
9
9
  This email verification link has expired. Not to worry, we can email
10
10
  you a new one.
11
11
  </p>
12
12
 
13
13
  <el-input
14
- class="AM-mt-2 AM-mb-2.5 hidden"
14
+ class="mt-2 mb-2.5 hidden"
15
15
  v-model="form.email"
16
16
  label="Email address"
17
17
  name="email"
@@ -32,7 +32,7 @@
32
32
  </elButton>
33
33
  </form>
34
34
 
35
- <p class="disclaimer AM-mt-3">
35
+ <p class="disclaimer mt-3">
36
36
  Having trouble singing in?
37
37
  <a :href="$store.state.auth.contact" class="underline">Contact us</a>
38
38
  </p>
@@ -40,6 +40,7 @@
40
40
 
41
41
  <script>
42
42
  import Form from "form-backend-validation";
43
+ import { ElNotification } from "element-plus";
43
44
 
44
45
  export default {
45
46
  components: {
@@ -66,28 +67,28 @@ export default {
66
67
 
67
68
  await this.form.post("/email/verification-notification");
68
69
 
69
- this.$notify.success({
70
+ ElNotification.success({
70
71
  message: "Email has been re-sent",
71
72
  duration: 10000,
72
73
  class: "el-notification--success el-notification--right-override",
73
74
  });
74
75
  } catch (e) {
75
76
  if (e.response && e.response.status === 429) {
76
- this.notification = this.$notify({
77
+ this.notification = ElNotification({
77
78
  type: "warning",
78
79
  message: "Please allow 10 minutes before re-requesting",
79
80
  duration: 0,
80
81
  class: "el-notification--warning el-notification--right-override",
81
82
  });
82
83
  } else if (e.response && e.response.status === 422) {
83
- this.notification = this.$notify({
84
+ this.notification = ElNotification({
84
85
  type: "error",
85
86
  message: e.response.data.message,
86
87
  duration: 0,
87
88
  class: "el-notification--error el-notification--right-override",
88
89
  });
89
90
  } else {
90
- this.$root.errors(e);
91
+ console.log(e);
91
92
  }
92
93
  }
93
94
  },
@@ -1,21 +1,14 @@
1
1
  <template>
2
2
  <div class="relative">
3
3
  <section id="resetPasswordForm">
4
- <h1
5
- class="h2 h2--small"
6
- v-html="!form.successful ? 'Welcome' : 'Success'"
7
- />
4
+ <h1 class="h2 h2--small" v-html="'Welcome'" />
8
5
  <form class="form" @submit.prevent="submit">
9
- <div v-if="!form.successful">
10
- <p class="AM-mt-2 AM-mb-0 AM-color-highlight">
11
- <strong class=""
12
- >Email:
13
- {{ $store.state?.auth?.user?.email }}</strong
14
- >
6
+ <div>
7
+ <p class="mt-2 mb-0 color-highlight">
8
+ <strong class="">Email: {{ email }}</strong>
15
9
  </p>
16
- <p class="AM-mt-0.5">
17
- <strong
18
- >Hello {{ $store.state?.auth?.user?.name }}</strong
10
+ <p class="mt-0.5">
11
+ <strong>Hello {{ name }}</strong
19
12
  >, and welcome to {{ $root.appName }}. To maintain
20
13
  security, anyone signing in with a one-time-password
21
14
  must <strong>create a new password</strong> the first
@@ -23,7 +16,7 @@
23
16
  </p>
24
17
  <el-input
25
18
  v-model="form.password"
26
- class="AM-mt-2"
19
+ class="mt-2"
27
20
  label="New Password"
28
21
  placeholder="Enter new password"
29
22
  name="password"
@@ -33,31 +26,22 @@
33
26
  required
34
27
  />
35
28
 
36
- <VPasswordValidation
29
+ <VelPasswordValidation
37
30
  :password="form.password"
38
31
  @passwordValid="updatePasswordValidity"
39
32
  />
40
33
 
41
34
  <elButton
42
35
  native-type="submit"
43
- class="AM-mt-3"
36
+ class="mt-3"
44
37
  type="primary"
45
- :disabled="form.processing || !isPasswordValid"
46
- :loading="form.processing"
38
+ :disabled="loading || !isPasswordValid"
39
+ :loading="loading"
47
40
  @click="onSubmit"
48
41
  >
49
42
  <span v-text="'Update password'" />
50
43
  </elButton>
51
44
  </div>
52
- <div v-else>
53
- <strong class=""
54
- >Email: {{ $store.state.auth?.user?.email }}</strong
55
- >
56
- <p v-text="`Your password has been updated.`" />
57
- <elButton type="primary" @click="handleButton">
58
- Continue
59
- </elButton>
60
- </div>
61
45
  </form>
62
46
  </section>
63
47
  </div>
@@ -65,8 +49,17 @@
65
49
 
66
50
  <script>
67
51
  import Form from "form-backend-validation";
52
+ import { ElNotification } from "element-plus";
68
53
 
69
54
  export default {
55
+ components: {
56
+ VelPasswordValidation:
57
+ require("../../../components/layout/PasswordValidation.vue")
58
+ .default,
59
+ elInput: require("../../../components/form/basic.vue").default,
60
+ elButton: require("../../../components/basic/Button.vue").default,
61
+ },
62
+
70
63
  data() {
71
64
  return {
72
65
  form: new Form(
@@ -77,13 +70,17 @@ export default {
77
70
  { resetOnSuccess: false },
78
71
  ),
79
72
  isPasswordValid: false,
73
+ loading: false,
74
+ name: "",
75
+ email: "",
80
76
  };
81
77
  },
82
78
 
83
79
  mounted() {
84
- this.$store.dispatch("getUser", {
85
- errors: this.$root.errors,
86
- });
80
+ this.$store.dispatch("getUser");
81
+
82
+ this.name = this.$store.state?.auth?.user?.name;
83
+ this.email = this.$store.state?.auth?.user?.email;
87
84
  },
88
85
 
89
86
  methods: {
@@ -94,46 +91,45 @@ export default {
94
91
  await this.form.put("/user/password");
95
92
  await this.login();
96
93
  } catch (e) {
97
- this.$root.errors(e);
94
+ console.log(e);
98
95
  } finally {
99
96
  this.loading = false;
100
97
  }
101
98
  },
102
99
  async login() {
103
- this.loading = true;
104
-
105
100
  try {
106
101
  const res = await this.form.post("/login");
107
102
 
108
103
  if (res["logged-in"]) {
109
104
  try {
110
- await this.$store.dispatch("logout", {
111
- errors: this.$root.errors,
112
- });
105
+ await this.$store.dispatch("logout");
113
106
  } catch (e) {}
114
107
 
115
108
  await this.form.post("/login");
116
109
  }
117
110
  } catch (e) {
118
- this.$root.errors(e);
111
+ console.log(e);
119
112
  } finally {
120
- this.loading = false;
121
113
  await this.postLogin();
122
114
  }
123
115
  },
124
116
 
125
117
  async postLogin() {
126
- const { data: user } = await this.$store.dispatch("getUser", {
127
- errors: this.$root.errors,
118
+ const { data: user } = await this.$store.dispatch("getUser");
119
+
120
+ this.$router.push({ name: this.$store.state.auth.redirect });
121
+
122
+ ElNotification({
123
+ type: "success",
124
+ message: "Password updated successfully",
125
+ duration: 10000,
126
+ class: "el-notification--success el-notification--right-override",
128
127
  });
129
128
  },
130
129
 
131
130
  updatePasswordValidity(isValid) {
132
131
  this.isPasswordValid = isValid;
133
132
  },
134
- handleButton() {
135
- this.$emit("close");
136
- },
137
133
  },
138
134
 
139
135
  metaInfo() {
@@ -141,12 +137,5 @@ export default {
141
137
  title: "Reset Password",
142
138
  };
143
139
  },
144
-
145
- components: {
146
- VPasswordValidation: require("./../components/VPasswordValidation.vue")
147
- .default,
148
- elInput: require("../../../components/form/basic.vue").default,
149
- elButton: require("../../../components/basic/Button.vue").default,
150
- },
151
140
  };
152
141
  </script>