@sowell/quasar-app-extension-auth 0.2.4 → 0.2.5
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/package.json +1 -1
- package/src/assets/error.svg +5 -0
- package/src/assets/success.svg +6 -0
- package/src/boot/router-guards.ts +2 -2
- package/src/components/dialogs/Message.vue +81 -0
- package/src/components/dialogs/SendEmail.vue +69 -0
- package/src/components/pages/Auth.vue +26 -48
- package/src/injects/prompts.ts +1 -0
- package/src/store/index.ts +6 -1
package/package.json
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg id="noun_Error_1688921" xmlns="http://www.w3.org/2000/svg" width="63" height="63" viewBox="0 0 63 63">
|
|
2
|
+
<circle id="Ellipse_90" data-name="Ellipse 90" cx="31.5" cy="31.5" r="31.5" fill="#f2d7d7"/>
|
|
3
|
+
<path id="Tracé_727" data-name="Tracé 727" d="M14.477,29.163h0A4.078,4.078,0,0,1,10.5,25.186V9.277A4.078,4.078,0,0,1,14.477,5.3h0a4.078,4.078,0,0,1,3.977,3.977V25.186A4.078,4.078,0,0,1,14.477,29.163Z" transform="translate(17.34 8.753)" fill="#ce0101"/>
|
|
4
|
+
<path id="Tracé_728" data-name="Tracé 728" d="M14.477,23.654h0A4.078,4.078,0,0,1,10.5,19.677h0A4.078,4.078,0,0,1,14.477,15.7h0a4.078,4.078,0,0,1,3.977,3.977h0A4.078,4.078,0,0,1,14.477,23.654Z" transform="translate(17.34 25.927)" fill="#ce0101"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="62" height="62" viewBox="0 0 62 62">
|
|
2
|
+
<g id="noun_validation_1683882" transform="translate(0.1 -0.4)">
|
|
3
|
+
<circle id="Ellipse_89" data-name="Ellipse 89" cx="31" cy="31" r="31" transform="translate(-0.1 0.4)" fill="#dff2d6"/>
|
|
4
|
+
<path id="Tracé_724" data-name="Tracé 724" d="M36.165,13.221a1.189,1.189,0,0,0-1.868.311L21.84,31.906l-8.253-8.253a1.169,1.169,0,0,0-1.868.156,1.667,1.667,0,0,0,.156,2.18l9.5,9.342h0c.156.156.156.156.311.156a.152.152,0,0,1,.156.156c.156,0,.311.156.623.156h0c.156,0,.467,0,.467-.156l.156-.156c.156,0,.156-.156.311-.156h0L36.632,15.713A2.752,2.752,0,0,0,36.165,13.221Z" transform="translate(6.399 6.953)" fill="#3b9843"/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -12,8 +12,8 @@ export default boot(({ router, store }: BootInterface) => {
|
|
|
12
12
|
let isValid = store.getters["token/getIsValid"];
|
|
13
13
|
let token = store.getters["token/getRaw"];
|
|
14
14
|
if (
|
|
15
|
-
!isValid
|
|
16
|
-
|
|
15
|
+
(!isValid ||
|
|
16
|
+
!token ) &&
|
|
17
17
|
to.path !== LOCAL_LOGIN_ROUTE &&
|
|
18
18
|
to.name !== "update_password"
|
|
19
19
|
) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<q-card style="min-width: 350px; border-radius: 30px">
|
|
3
|
+
<q-toolbar>
|
|
4
|
+
<q-space />
|
|
5
|
+
<q-btn
|
|
6
|
+
class="q-pt-md"
|
|
7
|
+
flat
|
|
8
|
+
dense
|
|
9
|
+
color="primary"
|
|
10
|
+
icon="close"
|
|
11
|
+
v-close-popup
|
|
12
|
+
/>
|
|
13
|
+
</q-toolbar>
|
|
14
|
+
<q-card-section class="text-center">
|
|
15
|
+
<img v-if="sendEmailSuccess" src="../../assets/success.svg" />
|
|
16
|
+
<img v-else src="../../assets/error.svg" />
|
|
17
|
+
</q-card-section>
|
|
18
|
+
|
|
19
|
+
<q-card-section class="q-pt-none q-pl-lg q-pr-lg">
|
|
20
|
+
<div
|
|
21
|
+
class="text-subtitle1 q-mt-sm text-center"
|
|
22
|
+
style="font-size: 14px; font-weigth: 300; line-height: 20px"
|
|
23
|
+
data-cy="resetMessage"
|
|
24
|
+
>
|
|
25
|
+
{{
|
|
26
|
+
sendEmailSuccess ? $t("auth.emailSent") : $t("auth.emailNotRecognize")
|
|
27
|
+
}}
|
|
28
|
+
</div>
|
|
29
|
+
<div
|
|
30
|
+
class="q-mt-sm text-center q-mb-xl"
|
|
31
|
+
style="font-size: 15px; color: #737676"
|
|
32
|
+
v-if="sendEmailSuccess"
|
|
33
|
+
>
|
|
34
|
+
{{ emailResetPassword }}
|
|
35
|
+
</div>
|
|
36
|
+
</q-card-section>
|
|
37
|
+
<q-card-actions class="q-ml-lg q-mr-lg q-mb-lg">
|
|
38
|
+
<q-btn
|
|
39
|
+
v-if="!sendEmailSuccess"
|
|
40
|
+
data-cy="submit-login"
|
|
41
|
+
rounded
|
|
42
|
+
:label="$t('auth.reSend')"
|
|
43
|
+
color="primary"
|
|
44
|
+
padding="10px 5px 10px 5px"
|
|
45
|
+
:loading="loading"
|
|
46
|
+
no-caps
|
|
47
|
+
type="submit"
|
|
48
|
+
@click="reSendEmail"
|
|
49
|
+
class="full-width"
|
|
50
|
+
/>
|
|
51
|
+
</q-card-actions>
|
|
52
|
+
</q-card>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script lang="ts">
|
|
56
|
+
import { defineComponent } from "vue";
|
|
57
|
+
|
|
58
|
+
export default defineComponent({
|
|
59
|
+
props: {
|
|
60
|
+
emailResetPassword: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: true,
|
|
63
|
+
},
|
|
64
|
+
sendEmailSuccess: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
loading: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
emit: ["resetPassword"],
|
|
74
|
+
setup(props: any, { emit }: any) {
|
|
75
|
+
const reSendEmail = () => {
|
|
76
|
+
emit("reSendEmail");
|
|
77
|
+
};
|
|
78
|
+
return { reSendEmail };
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
</script>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<q-card style="min-width: 350px; border-radius: 30px">
|
|
3
|
+
<q-toolbar>
|
|
4
|
+
<q-space />
|
|
5
|
+
<q-btn
|
|
6
|
+
class="q-pt-md"
|
|
7
|
+
flat
|
|
8
|
+
dense
|
|
9
|
+
color="primary"
|
|
10
|
+
icon="close"
|
|
11
|
+
v-close-popup
|
|
12
|
+
/>
|
|
13
|
+
</q-toolbar>
|
|
14
|
+
<q-card-section>
|
|
15
|
+
<p
|
|
16
|
+
class="resetPasswordTitle text-center"
|
|
17
|
+
style="font-size: 20px; font-weigth: 600"
|
|
18
|
+
>
|
|
19
|
+
{{ $t("auth.tapEmail") }}
|
|
20
|
+
</p>
|
|
21
|
+
</q-card-section>
|
|
22
|
+
|
|
23
|
+
<q-card-section class="q-pt-none q-pl-lg q-pr-lg">
|
|
24
|
+
<q-input
|
|
25
|
+
v-model="email"
|
|
26
|
+
dense
|
|
27
|
+
outlined
|
|
28
|
+
data-cy="emailReset"
|
|
29
|
+
:placeholder="$t('auth.email')"
|
|
30
|
+
autofocus
|
|
31
|
+
/>
|
|
32
|
+
<div
|
|
33
|
+
class="text-subtitle1 q-mt-sm"
|
|
34
|
+
style="font-size: 13px; font-weigth: 300; line-height: 20px"
|
|
35
|
+
>
|
|
36
|
+
{{ $t("auth.resetText") }}
|
|
37
|
+
</div>
|
|
38
|
+
</q-card-section>
|
|
39
|
+
|
|
40
|
+
<q-card-actions align="center" class="q-ml-lg q-mr-lg q-mb-lg">
|
|
41
|
+
<q-btn
|
|
42
|
+
rounded
|
|
43
|
+
color="primary"
|
|
44
|
+
data-cy="sendEmails"
|
|
45
|
+
no-caps
|
|
46
|
+
:label="$t('common.reset')"
|
|
47
|
+
class="btn-min full-width"
|
|
48
|
+
@click="sendEmail"
|
|
49
|
+
v-close-popup
|
|
50
|
+
/>
|
|
51
|
+
</q-card-actions>
|
|
52
|
+
</q-card>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script lang="ts">
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
import { defineComponent, ref } from "vue";
|
|
58
|
+
|
|
59
|
+
export default defineComponent({
|
|
60
|
+
emit: ["resetPassword"],
|
|
61
|
+
setup(props: any, { emit }: any) {
|
|
62
|
+
const email = ref("");
|
|
63
|
+
const sendEmail = () => {
|
|
64
|
+
emit("resetPassword", email.value);
|
|
65
|
+
};
|
|
66
|
+
return { sendEmail, email };
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
<div
|
|
44
44
|
class="q-mb-xl"
|
|
45
45
|
@click="forgottenPassword = true"
|
|
46
|
+
data-cy="forgot-password"
|
|
46
47
|
style="color: #40c4ff; font-weight: 500; cursor: pointer"
|
|
47
48
|
>
|
|
48
49
|
{{ $t("auth.forgottenPassword") }}
|
|
@@ -63,41 +64,15 @@
|
|
|
63
64
|
</div>
|
|
64
65
|
<div>
|
|
65
66
|
<q-dialog v-model="forgottenPassword" persistent>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
v-model="emailResetPassword"
|
|
76
|
-
dense
|
|
77
|
-
rounded
|
|
78
|
-
outlined
|
|
79
|
-
:placeholder="$t('auth.email')"
|
|
80
|
-
autofocus
|
|
81
|
-
/>
|
|
82
|
-
</q-card-section>
|
|
83
|
-
|
|
84
|
-
<q-card-actions align="right">
|
|
85
|
-
<q-btn
|
|
86
|
-
outline
|
|
87
|
-
rounded
|
|
88
|
-
:label="$t('common.cancel')"
|
|
89
|
-
class="btn-min"
|
|
90
|
-
v-close-popup
|
|
91
|
-
/>
|
|
92
|
-
<q-btn
|
|
93
|
-
rounded
|
|
94
|
-
color="primary"
|
|
95
|
-
:label="$t('common.send')"
|
|
96
|
-
class="btn-min"
|
|
97
|
-
@click="resetPassword"
|
|
98
|
-
/>
|
|
99
|
-
</q-card-actions>
|
|
100
|
-
</q-card>
|
|
67
|
+
<send-email @resetPassword="resetPassword" />
|
|
68
|
+
</q-dialog>
|
|
69
|
+
<q-dialog v-model="isReset" persistent>
|
|
70
|
+
<sowell-message
|
|
71
|
+
:emailResetPassword="emailResetPassword"
|
|
72
|
+
:sendEmailSuccess="sendEmailSuccess"
|
|
73
|
+
:loading="loading"
|
|
74
|
+
@reSendEmail="resetPassword"
|
|
75
|
+
/>
|
|
101
76
|
</q-dialog>
|
|
102
77
|
</div>
|
|
103
78
|
</q-page>
|
|
@@ -105,7 +80,6 @@
|
|
|
105
80
|
</template>
|
|
106
81
|
|
|
107
82
|
<script lang="ts">
|
|
108
|
-
//import prompts from "app/quasar.extensions.json";
|
|
109
83
|
import isEmail from "validator/es/lib/isEmail";
|
|
110
84
|
import { defineComponent, ref, onMounted } from "vue";
|
|
111
85
|
import { $api, $prompts, $router, $store } from "../../injects";
|
|
@@ -113,6 +87,8 @@ import { useQuasar } from "quasar";
|
|
|
113
87
|
import { useI18n } from "vue-i18n";
|
|
114
88
|
import { AxiosError, AxiosResponse } from "axios";
|
|
115
89
|
import prompts from "app/quasar.extensions.json";
|
|
90
|
+
import SendEmail from "../dialogs/SendEmail.vue";
|
|
91
|
+
import SowellMessage from "../dialogs/Message.vue";
|
|
116
92
|
|
|
117
93
|
interface HeadersInterface {
|
|
118
94
|
headers: {
|
|
@@ -122,6 +98,7 @@ interface HeadersInterface {
|
|
|
122
98
|
|
|
123
99
|
export default defineComponent({
|
|
124
100
|
name: "Auth",
|
|
101
|
+
components: { SendEmail, SowellMessage },
|
|
125
102
|
setup() {
|
|
126
103
|
const {
|
|
127
104
|
"@sowell/auth": { X_REQUESTED_ROLES },
|
|
@@ -131,12 +108,15 @@ export default defineComponent({
|
|
|
131
108
|
const loading = ref(false);
|
|
132
109
|
const showPassword = ref(false);
|
|
133
110
|
const forgottenPassword = ref(false);
|
|
111
|
+
const isReset = ref(false);
|
|
112
|
+
const sendEmailSuccess = ref(false);
|
|
134
113
|
const emailResetPassword = ref("");
|
|
135
114
|
const { post } = $api();
|
|
136
115
|
const {
|
|
137
116
|
LOCAL_SUCCESS_REDIRECTION_ROUTE,
|
|
138
117
|
AUTH_SERVER_SIGNING_ROUTE,
|
|
139
118
|
AUTH_SERVER_RESET_PASSWORD_ROUTE,
|
|
119
|
+
APP_SERVER_BASE_URL,
|
|
140
120
|
} = $prompts();
|
|
141
121
|
const $q = useQuasar();
|
|
142
122
|
const { push, replace } = $router();
|
|
@@ -157,26 +137,22 @@ export default defineComponent({
|
|
|
157
137
|
password: [(val: string) => !!val || t("auth.passwordPresenceError")],
|
|
158
138
|
});
|
|
159
139
|
|
|
160
|
-
const resetPassword = () => {
|
|
140
|
+
const resetPassword = (email: string) => {
|
|
161
141
|
const data = {
|
|
162
|
-
|
|
142
|
+
auth: {
|
|
143
|
+
email,
|
|
144
|
+
base: APP_SERVER_BASE_URL,
|
|
145
|
+
},
|
|
163
146
|
};
|
|
164
147
|
|
|
165
148
|
post(AUTH_SERVER_RESET_PASSWORD_ROUTE, data)
|
|
166
149
|
.then(() => {
|
|
167
|
-
$q.notify({
|
|
168
|
-
message: t("auth.emailSent"),
|
|
169
|
-
color: "positive",
|
|
170
|
-
position: "top",
|
|
171
|
-
});
|
|
172
150
|
forgottenPassword.value = false;
|
|
151
|
+
isReset.value = true;
|
|
152
|
+
sendEmailSuccess.value = true;
|
|
173
153
|
})
|
|
174
154
|
.catch(() => {
|
|
175
|
-
|
|
176
|
-
message: t("auth.emailNotRecognize"),
|
|
177
|
-
color: "negative",
|
|
178
|
-
position: "top",
|
|
179
|
-
});
|
|
155
|
+
isReset.value = true;
|
|
180
156
|
});
|
|
181
157
|
};
|
|
182
158
|
|
|
@@ -251,6 +227,8 @@ export default defineComponent({
|
|
|
251
227
|
forgottenPassword,
|
|
252
228
|
emailResetPassword,
|
|
253
229
|
resetPassword,
|
|
230
|
+
isReset,
|
|
231
|
+
sendEmailSuccess,
|
|
254
232
|
};
|
|
255
233
|
},
|
|
256
234
|
});
|
package/src/injects/prompts.ts
CHANGED
package/src/store/index.ts
CHANGED
|
@@ -50,7 +50,12 @@ const mutations: MutationTree<tokenStateInterface> = {
|
|
|
50
50
|
const actions: ActionTree<tokenStateInterface, any> = {
|
|
51
51
|
updateRaw({ commit }, value: string) {
|
|
52
52
|
commit("setRaw", value);
|
|
53
|
-
|
|
53
|
+
let parseJwt: string
|
|
54
|
+
try {
|
|
55
|
+
parseJwt = JSON.parse(window.atob(value.split(".")[1]));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
parseJwt = ""
|
|
58
|
+
}
|
|
54
59
|
commit("setPayload", parseJwt)
|
|
55
60
|
}
|
|
56
61
|
}
|