@sowell/quasar-app-extension-auth 1.1.1 → 1.1.2
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
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<q-card
|
|
2
|
+
<q-card
|
|
3
|
+
style="max-width: 343px; border-radius: 10px; background: #f4f5f6"
|
|
4
|
+
data-testid="feedback-dialog">
|
|
3
5
|
<q-card-section class="text-center q-mt-lg">
|
|
4
6
|
<img
|
|
5
7
|
v-if="emailSended"
|
|
6
8
|
src="../../assets/mailbox.svg"
|
|
7
|
-
style="width: 175px; height: 150px"
|
|
8
|
-
/>
|
|
9
|
+
style="width: 175px; height: 150px" />
|
|
9
10
|
<img
|
|
10
11
|
v-if="passwordUpdated"
|
|
11
12
|
src="../../assets/success.svg"
|
|
12
|
-
style="width: 100px; height: 80px"
|
|
13
|
-
/>
|
|
13
|
+
style="width: 100px; height: 80px" />
|
|
14
14
|
<img
|
|
15
15
|
v-if="emailNotSend"
|
|
16
16
|
src="../../assets/error.svg"
|
|
17
|
-
style="width: 100px; height: 80px"
|
|
18
|
-
/>
|
|
17
|
+
style="width: 100px; height: 80px" />
|
|
19
18
|
</q-card-section>
|
|
20
19
|
|
|
21
20
|
<q-card-section class="q-pt-none q-pl-lg q-pr-lg">
|
|
@@ -23,29 +22,26 @@
|
|
|
23
22
|
class="text-subtitle1 q-mt-sm q-mb-md text-center text-dark"
|
|
24
23
|
style="font-size: 24px; font-weight: 600"
|
|
25
24
|
data-cy="resetErrorMessage"
|
|
26
|
-
data-testid="header-dialog"
|
|
27
|
-
>
|
|
25
|
+
data-testid="header-dialog">
|
|
28
26
|
{{ messageTitle }}
|
|
29
27
|
</div>
|
|
30
28
|
<div
|
|
31
29
|
data-cy="resetMessage"
|
|
32
30
|
data-testid="message-dialog"
|
|
33
31
|
class="text-subtitle1 q-mt-sm text-center"
|
|
34
|
-
style="font-size: 16px; font-weight: 400"
|
|
35
|
-
>
|
|
32
|
+
style="font-size: 16px; font-weight: 400">
|
|
36
33
|
{{ messageSubtitle }}
|
|
37
34
|
</div>
|
|
38
35
|
<div
|
|
39
36
|
class="q-mt-sm text-center q-mb-xl"
|
|
40
37
|
style="font-size: 15px; color: #737676"
|
|
41
|
-
v-if="
|
|
42
|
-
>
|
|
38
|
+
v-if="sendEmailCode === 200">
|
|
43
39
|
{{ emailResetPassword }}
|
|
44
40
|
</div>
|
|
45
41
|
</q-card-section>
|
|
46
42
|
<q-card-actions class="q-ml-lg q-mr-lg q-mb-lg">
|
|
47
43
|
<q-btn
|
|
48
|
-
v-if="emailNotSend"
|
|
44
|
+
v-if="emailNotSend && sendEmailCode !== 403"
|
|
49
45
|
data-cy="submit-login"
|
|
50
46
|
:label="$t('auth.reSend')"
|
|
51
47
|
color="primary"
|
|
@@ -55,8 +51,7 @@
|
|
|
55
51
|
unelevated
|
|
56
52
|
type="submit"
|
|
57
53
|
@click="retypeEmail"
|
|
58
|
-
class="full-width"
|
|
59
|
-
/>
|
|
54
|
+
class="full-width" />
|
|
60
55
|
<slot>
|
|
61
56
|
<q-btn
|
|
62
57
|
data-testid="close-btn"
|
|
@@ -68,24 +63,23 @@
|
|
|
68
63
|
no-caps
|
|
69
64
|
:label="$t('auth.close')"
|
|
70
65
|
color="dark"
|
|
71
|
-
v-close-popup
|
|
72
|
-
/>
|
|
66
|
+
v-close-popup />
|
|
73
67
|
</slot>
|
|
74
68
|
</q-card-actions>
|
|
75
69
|
</q-card>
|
|
76
70
|
</template>
|
|
77
71
|
|
|
78
72
|
<script lang="ts">
|
|
79
|
-
import { defineComponent, computed } from "vue"
|
|
80
|
-
import { useI18n } from "vue-i18n"
|
|
73
|
+
import { defineComponent, computed } from "vue"
|
|
74
|
+
import { useI18n } from "vue-i18n"
|
|
81
75
|
|
|
82
76
|
export default defineComponent({
|
|
83
77
|
props: {
|
|
84
78
|
emailResetPassword: {
|
|
85
79
|
type: String
|
|
86
80
|
},
|
|
87
|
-
|
|
88
|
-
type:
|
|
81
|
+
sendEmailCode: {
|
|
82
|
+
type: Number
|
|
89
83
|
},
|
|
90
84
|
loading: {
|
|
91
85
|
type: Boolean
|
|
@@ -98,34 +92,40 @@ export default defineComponent({
|
|
|
98
92
|
setup(props: any, { emit }: any) {
|
|
99
93
|
const { t } = useI18n()
|
|
100
94
|
|
|
101
|
-
const messageSubtitle = computed(() =>
|
|
102
|
-
props.
|
|
95
|
+
const messageSubtitle = computed(() => {
|
|
96
|
+
if (props.sendEmailCode === 403) {
|
|
97
|
+
return t("auth.forbidden.subtitle")
|
|
98
|
+
}
|
|
99
|
+
return props.sendEmailCode === 200
|
|
103
100
|
? t("auth.emailSent")
|
|
104
101
|
: !props.passwordUpdated
|
|
105
102
|
? t("auth.emailNotRecognize")
|
|
106
103
|
: t("auth.passwordUpdated")
|
|
107
|
-
)
|
|
108
|
-
const messageTitle = computed(() =>
|
|
109
|
-
props.
|
|
104
|
+
})
|
|
105
|
+
const messageTitle = computed(() => {
|
|
106
|
+
if (props.sendEmailCode === 403) {
|
|
107
|
+
return t("auth.forbidden.title")
|
|
108
|
+
}
|
|
109
|
+
return props.sendEmailCode === 200
|
|
110
110
|
? t("auth.emailVerification")
|
|
111
111
|
: !props.passwordUpdated
|
|
112
112
|
? t("auth.loginFailed")
|
|
113
113
|
: t("auth.passwordChanged")
|
|
114
|
-
)
|
|
114
|
+
})
|
|
115
115
|
|
|
116
116
|
const emailNotSend = computed(
|
|
117
|
-
() =>
|
|
117
|
+
() => props.sendEmailCode !== 200 && !props.passwordUpdated
|
|
118
118
|
)
|
|
119
119
|
const emailSended = computed(
|
|
120
|
-
() => props.
|
|
120
|
+
() => props.sendEmailCode === 200 && !props.passwordUpdated
|
|
121
121
|
)
|
|
122
122
|
|
|
123
123
|
const retypeEmail = () => {
|
|
124
124
|
emit("retypeEmail")
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const handlePasswordUpdate = () =>{
|
|
128
|
-
if(props.passwordUpdated){
|
|
127
|
+
const handlePasswordUpdate = () => {
|
|
128
|
+
if (props.passwordUpdated) {
|
|
129
129
|
emit("goToLoginPage")
|
|
130
130
|
} else {
|
|
131
131
|
emit("close")
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
<q-dialog v-model="isReset" persistent>
|
|
135
135
|
<sowell-message
|
|
136
136
|
:emailResetPassword="emailResetPassword"
|
|
137
|
-
:
|
|
137
|
+
:sendEmailCode="sendEmailCode"
|
|
138
138
|
:loading="loading"
|
|
139
139
|
@retypeEmail="retypeEmail"
|
|
140
140
|
@close="() => isReset= false"/>
|
|
@@ -162,6 +162,7 @@ import SowellMessage from "../dialogs/Message.vue"
|
|
|
162
162
|
import MicrosoftLogo from "../../assets/logo-microsoft.svg"
|
|
163
163
|
|
|
164
164
|
import { useAuth } from "composables/auth"
|
|
165
|
+
import { send } from "process"
|
|
165
166
|
|
|
166
167
|
export default defineComponent({
|
|
167
168
|
name: "Auth",
|
|
@@ -177,7 +178,7 @@ export default defineComponent({
|
|
|
177
178
|
forgottenPassword,
|
|
178
179
|
emailResetPassword,
|
|
179
180
|
isReset,
|
|
180
|
-
|
|
181
|
+
sendEmailCode,
|
|
181
182
|
authState,
|
|
182
183
|
APP_SERVER_BASE_URL,
|
|
183
184
|
icons,
|
|
@@ -201,11 +202,11 @@ export default defineComponent({
|
|
|
201
202
|
try {
|
|
202
203
|
forgottenPassword.value = false
|
|
203
204
|
await authState.resetPassword(data).then(() => {
|
|
204
|
-
|
|
205
|
+
sendEmailCode.value = 200
|
|
205
206
|
isReset.value = true
|
|
206
207
|
})
|
|
207
208
|
} catch {
|
|
208
|
-
|
|
209
|
+
sendEmailCode.value = 404
|
|
209
210
|
isReset.value = true
|
|
210
211
|
}
|
|
211
212
|
}
|
|
@@ -228,7 +229,7 @@ export default defineComponent({
|
|
|
228
229
|
forgottenPassword,
|
|
229
230
|
emailResetPassword,
|
|
230
231
|
isReset,
|
|
231
|
-
|
|
232
|
+
sendEmailCode,
|
|
232
233
|
icons,
|
|
233
234
|
appVersion,
|
|
234
235
|
USE_SSO,
|
|
@@ -7,13 +7,11 @@
|
|
|
7
7
|
<img
|
|
8
8
|
src="../../assets/Logo.svg"
|
|
9
9
|
class="q-mb-sm q-mr-md"
|
|
10
|
-
style="width: 27px; height: 47px"
|
|
11
|
-
/>
|
|
10
|
+
style="width: 27px; height: 47px" />
|
|
12
11
|
<img
|
|
13
12
|
src="../../assets/Sowell.svg"
|
|
14
13
|
class="q-mb-sm"
|
|
15
|
-
style="width: 146px; height: 38px"
|
|
16
|
-
/>
|
|
14
|
+
style="width: 146px; height: 38px" />
|
|
17
15
|
</div>
|
|
18
16
|
</div>
|
|
19
17
|
<div class="login-page">
|
|
@@ -21,8 +19,7 @@
|
|
|
21
19
|
<div>
|
|
22
20
|
<div
|
|
23
21
|
class="q-ml-xs q-mb-xs"
|
|
24
|
-
style="font-size: 14px; font-weight: 600"
|
|
25
|
-
>
|
|
22
|
+
style="font-size: 14px; font-weight: 600">
|
|
26
23
|
{{ $t("auth.email") }}
|
|
27
24
|
</div>
|
|
28
25
|
<q-input
|
|
@@ -32,8 +29,7 @@
|
|
|
32
29
|
borderless
|
|
33
30
|
:rules="validations['email']"
|
|
34
31
|
lazy-rules
|
|
35
|
-
:input-style="{ fontSize: '14px', fontWeight: '500' }"
|
|
36
|
-
>
|
|
32
|
+
:input-style="{ fontSize: '14px', fontWeight: '500' }">
|
|
37
33
|
<template #prepend>
|
|
38
34
|
<q-icon :name="icons.ionMailOutline" />
|
|
39
35
|
</template>
|
|
@@ -42,8 +38,7 @@
|
|
|
42
38
|
<div>
|
|
43
39
|
<div
|
|
44
40
|
class="q-ml-xs q-mb-xs"
|
|
45
|
-
style="font-size: 14px; font-weight: 600"
|
|
46
|
-
>
|
|
41
|
+
style="font-size: 14px; font-weight: 600">
|
|
47
42
|
{{ $t("auth.password") }}
|
|
48
43
|
</div>
|
|
49
44
|
<q-input
|
|
@@ -54,8 +49,7 @@
|
|
|
54
49
|
lazy-rules
|
|
55
50
|
borderless
|
|
56
51
|
dense
|
|
57
|
-
:input-style="{ fontSize: '14px', fontWeight: '600' }"
|
|
58
|
-
>
|
|
52
|
+
:input-style="{ fontSize: '14px', fontWeight: '600' }">
|
|
59
53
|
<template #prepend>
|
|
60
54
|
<q-icon :name="icons.ionLockClosedOutline" />
|
|
61
55
|
</template>
|
|
@@ -67,15 +61,13 @@
|
|
|
67
61
|
: icons.ionEyeOutline
|
|
68
62
|
"
|
|
69
63
|
class="cursor-pointer q-mr-sm"
|
|
70
|
-
@click="showPassword = !showPassword"
|
|
71
|
-
/>
|
|
64
|
+
@click="showPassword = !showPassword" />
|
|
72
65
|
</template>
|
|
73
66
|
</q-input>
|
|
74
67
|
</div>
|
|
75
68
|
<div
|
|
76
69
|
v-if="errorEmailMessage || errorPasswordMessage"
|
|
77
|
-
class="q-pl-sm text-red column justify-center error_input"
|
|
78
|
-
>
|
|
70
|
+
class="q-pl-sm text-red column justify-center error_input">
|
|
79
71
|
<div>{{ errorEmailMessage }}</div>
|
|
80
72
|
<div>{{ errorPasswordMessage }}</div>
|
|
81
73
|
</div>
|
|
@@ -89,8 +81,7 @@
|
|
|
89
81
|
:loading="loading"
|
|
90
82
|
type="submit"
|
|
91
83
|
class="full-width q-mt-lg"
|
|
92
|
-
:disable="isSubmitBtnDisabled()"
|
|
93
|
-
>
|
|
84
|
+
:disable="isSubmitBtnDisabled()">
|
|
94
85
|
<div style="font-weight: 600; font-size: 16px">
|
|
95
86
|
{{ $t("auth.login") }}
|
|
96
87
|
</div>
|
|
@@ -101,8 +92,7 @@
|
|
|
101
92
|
@click="forgottenPassword = true"
|
|
102
93
|
data-testid="ask-password-change-btn"
|
|
103
94
|
data-cy="forgot-password"
|
|
104
|
-
style="font-size: 14px; cursor: pointer; width: 350px"
|
|
105
|
-
>
|
|
95
|
+
style="font-size: 14px; cursor: pointer; width: 350px">
|
|
106
96
|
{{ $t("auth.forgottenPassword") }}
|
|
107
97
|
</div>
|
|
108
98
|
</div>
|
|
@@ -117,20 +107,20 @@
|
|
|
117
107
|
transition-show="fade"
|
|
118
108
|
transition-hide="fade"
|
|
119
109
|
persistent
|
|
120
|
-
data-testid="ask-password-change-modal"
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
data-testid="ask-password-change-modal">
|
|
111
|
+
<send-email
|
|
112
|
+
@resetPassword="resetPassword"
|
|
113
|
+
@close="() => (forgottenPassword = false)" />
|
|
123
114
|
</q-dialog>
|
|
124
115
|
<q-dialog v-model="isReset" persistent>
|
|
125
116
|
<sowell-message
|
|
126
117
|
:emailResetPassword="emailResetPassword"
|
|
127
|
-
:
|
|
118
|
+
:sendEmailCode="sendEmailCode"
|
|
128
119
|
:loading="loading"
|
|
129
120
|
@retypeEmail="retypeEmail"
|
|
130
|
-
@close="() => isReset = false"
|
|
131
|
-
>
|
|
121
|
+
@close="() => (isReset = false)">
|
|
132
122
|
<q-btn
|
|
133
|
-
v-if="
|
|
123
|
+
v-if="sendEmailCode === 200 && isOtp"
|
|
134
124
|
data-testid="next-btn"
|
|
135
125
|
class="q-mt-md full-width"
|
|
136
126
|
unelevated
|
|
@@ -140,8 +130,7 @@
|
|
|
140
130
|
no-caps
|
|
141
131
|
:label="$t('auth.next')"
|
|
142
132
|
color="dark"
|
|
143
|
-
v-close-popup
|
|
144
|
-
/>
|
|
133
|
+
v-close-popup />
|
|
145
134
|
</sowell-message>
|
|
146
135
|
</q-dialog>
|
|
147
136
|
</div>
|
|
@@ -164,6 +153,7 @@ import * as packageInfo from "app/package.json"
|
|
|
164
153
|
import SendEmail from "../dialogs/SendEmail.vue"
|
|
165
154
|
import SowellMessage from "../dialogs/Message.vue"
|
|
166
155
|
import { useAuth } from "composables/auth"
|
|
156
|
+
import { AxiosError } from "axios"
|
|
167
157
|
|
|
168
158
|
export default defineComponent({
|
|
169
159
|
name: "Auth",
|
|
@@ -180,7 +170,7 @@ export default defineComponent({
|
|
|
180
170
|
forgottenPassword,
|
|
181
171
|
emailResetPassword,
|
|
182
172
|
isReset,
|
|
183
|
-
|
|
173
|
+
sendEmailCode,
|
|
184
174
|
authState,
|
|
185
175
|
APP_SERVER_BASE_URL,
|
|
186
176
|
IS_OTP,
|
|
@@ -206,20 +196,26 @@ export default defineComponent({
|
|
|
206
196
|
auth: {
|
|
207
197
|
email,
|
|
208
198
|
base: APP_SERVER_BASE_URL
|
|
209
|
-
}
|
|
199
|
+
}
|
|
210
200
|
}
|
|
211
201
|
try {
|
|
212
202
|
forgottenPassword.value = false
|
|
213
203
|
await authState.resetPassword(data).then(() => {
|
|
214
204
|
localStorage.setItem("emailResetPassword", email)
|
|
215
|
-
|
|
205
|
+
sendEmailCode.value = 200
|
|
216
206
|
isReset.value = true
|
|
217
207
|
})
|
|
218
|
-
} catch {
|
|
219
|
-
|
|
208
|
+
} catch (error) {
|
|
209
|
+
if ((error as AxiosError).response?.status === 403) {
|
|
210
|
+
// NOTE: 403 is returned when the user is not allowed to reset the password
|
|
211
|
+
sendEmailCode.value = 403
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
sendEmailCode.value = 404
|
|
215
|
+
}
|
|
220
216
|
isReset.value = true
|
|
221
217
|
}
|
|
222
|
-
}
|
|
218
|
+
}
|
|
223
219
|
|
|
224
220
|
onMounted(() => {
|
|
225
221
|
appVersion.versionNumber = packageInfo.version
|
|
@@ -236,7 +232,7 @@ export default defineComponent({
|
|
|
236
232
|
forgottenPassword,
|
|
237
233
|
emailResetPassword,
|
|
238
234
|
isReset,
|
|
239
|
-
|
|
235
|
+
sendEmailCode,
|
|
240
236
|
icons,
|
|
241
237
|
appVersion,
|
|
242
238
|
isOtp,
|
|
@@ -264,4 +260,3 @@ export default defineComponent({
|
|
|
264
260
|
display: none;
|
|
265
261
|
}
|
|
266
262
|
</style>
|
|
267
|
-
|
package/src/composables/auth.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function useAuth() {
|
|
|
61
61
|
const showPassword = ref(false)
|
|
62
62
|
const forgottenPassword = ref(false)
|
|
63
63
|
const isReset = ref(false)
|
|
64
|
-
const
|
|
64
|
+
const sendEmailCode = ref(0)
|
|
65
65
|
const emailResetPassword = ref("")
|
|
66
66
|
const errorEmailMessage = ref("")
|
|
67
67
|
const errorPasswordMessage = ref("")
|
|
@@ -227,7 +227,7 @@ export function useAuth() {
|
|
|
227
227
|
forgottenPassword,
|
|
228
228
|
emailResetPassword,
|
|
229
229
|
isReset,
|
|
230
|
-
|
|
230
|
+
sendEmailCode,
|
|
231
231
|
authState,
|
|
232
232
|
APP_SERVER_BASE_URL,
|
|
233
233
|
WELCOME_TITLE,
|