@sowell/quasar-app-extension-auth 1.4.0 → 1.4.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
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<div class="column">
|
|
19
19
|
<div class="login-page">
|
|
20
20
|
<q-form @submit="handleSubmit">
|
|
21
|
-
<div style="margin-top:
|
|
21
|
+
<div style="margin-top: 22px" class="q-mx-lg input-container">
|
|
22
22
|
<div class="input-label">
|
|
23
23
|
{{ $t("auth.email") }}
|
|
24
24
|
</div>
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
v-model.trim="email"
|
|
28
28
|
type="email"
|
|
29
29
|
borderless
|
|
30
|
-
dense
|
|
31
30
|
:rules="validations['email']"
|
|
32
31
|
placeholder="Yourname@gmail.com"
|
|
33
32
|
lazy-rules
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
placeholder="********"
|
|
52
51
|
lazy-rules
|
|
53
52
|
borderless
|
|
54
|
-
dense
|
|
55
53
|
class="q-px-none q-mt-sm"
|
|
56
54
|
:class="{ 'input-error': errorPasswordMessage }"
|
|
57
55
|
:input-style="{ fontSize: '13px', fontWeight: '500' }">
|
|
@@ -81,7 +79,7 @@
|
|
|
81
79
|
text-color="white"
|
|
82
80
|
:loading="loading"
|
|
83
81
|
type="submit"
|
|
84
|
-
class="full-width q-mt-
|
|
82
|
+
class="full-width q-mt-lg login-button"
|
|
85
83
|
:disable="isSubmitBtnDisabled()">
|
|
86
84
|
<div style="font-weight: 500; font-size: 18px">
|
|
87
85
|
{{ $t("auth.login") }}
|
|
@@ -90,7 +88,7 @@
|
|
|
90
88
|
</div>
|
|
91
89
|
<div
|
|
92
90
|
class="forgot-password-link self-start"
|
|
93
|
-
style="font-weight: 500; margin: 12px 0"
|
|
91
|
+
style="font-weight: 500; margin: 12px 0; text-decoration: underline;"
|
|
94
92
|
@click="forgottenPassword = true"
|
|
95
93
|
data-testid="ask-password-change-btn"
|
|
96
94
|
data-cy="forgot-password">
|
|
@@ -129,19 +127,10 @@
|
|
|
129
127
|
</div>
|
|
130
128
|
<div class="error-message-container">
|
|
131
129
|
<div
|
|
132
|
-
v-if="
|
|
130
|
+
v-if="apiErrorMessage"
|
|
133
131
|
class="text-red column justify-center error_input">
|
|
134
132
|
<ErrorMessage
|
|
135
|
-
|
|
136
|
-
:message="errorEmailMessage"
|
|
137
|
-
class="error-message-item" />
|
|
138
|
-
<ErrorMessage
|
|
139
|
-
v-if="errorPasswordMessage && !errorEmailMessage"
|
|
140
|
-
:message="errorPasswordMessage"
|
|
141
|
-
class="error-message-item" />
|
|
142
|
-
<ErrorMessage
|
|
143
|
-
v-if="errorEmailMessage && errorPasswordMessage"
|
|
144
|
-
:message="$t('auth.emailOrPasswordIncorrect')"
|
|
133
|
+
:message="apiErrorMessage"
|
|
145
134
|
class="error-message-item" />
|
|
146
135
|
</div>
|
|
147
136
|
<div v-else class="error-placeholder q-mt-sm"></div>
|
|
@@ -186,7 +175,7 @@
|
|
|
186
175
|
</div>
|
|
187
176
|
</div>
|
|
188
177
|
<div class="row justify-between full-width items-center q-px-md q-mt-auto">
|
|
189
|
-
<div class="row justify-end footer-text" @click="goToPrivacyPolicy" style="cursor: pointer">
|
|
178
|
+
<div class="row justify-end footer-text" @click="goToPrivacyPolicy" style="cursor: pointer; text-decoration: underline;">
|
|
190
179
|
{{ $t("common.privacyPolicy") }}
|
|
191
180
|
</div>
|
|
192
181
|
<div class="row justify-end footer-text">
|
|
@@ -204,6 +193,7 @@ import SowellMessage from "../dialogs/Message.vue"
|
|
|
204
193
|
import ErrorMessage from "../ErrorMessage.vue"
|
|
205
194
|
import { useAuth } from "composables/auth"
|
|
206
195
|
import { AxiosError } from "axios"
|
|
196
|
+
import { useQuasar } from "quasar"
|
|
207
197
|
|
|
208
198
|
export default defineComponent({
|
|
209
199
|
name: "Auth",
|
|
@@ -217,6 +207,7 @@ export default defineComponent({
|
|
|
217
207
|
validations,
|
|
218
208
|
errorEmailMessage,
|
|
219
209
|
errorPasswordMessage,
|
|
210
|
+
apiErrorMessage,
|
|
220
211
|
forgottenPassword,
|
|
221
212
|
emailResetPassword,
|
|
222
213
|
isReset,
|
|
@@ -234,6 +225,8 @@ export default defineComponent({
|
|
|
234
225
|
goToOtpValidation
|
|
235
226
|
} = useAuth()
|
|
236
227
|
|
|
228
|
+
const { localStorage } = useQuasar()
|
|
229
|
+
|
|
237
230
|
const handleSubmit = () => {
|
|
238
231
|
onSubmit()
|
|
239
232
|
}
|
|
@@ -275,8 +268,10 @@ export default defineComponent({
|
|
|
275
268
|
|
|
276
269
|
onMounted(() => {
|
|
277
270
|
appVersion.versionNumber = packageInfo.version
|
|
278
|
-
|
|
279
|
-
|
|
271
|
+
if (localStorage.has("lastUser")) {
|
|
272
|
+
const lastUserEmail = localStorage.getItem("lastUser")
|
|
273
|
+
if (lastUserEmail) email.value = lastUserEmail
|
|
274
|
+
}
|
|
280
275
|
})
|
|
281
276
|
|
|
282
277
|
return {
|
|
@@ -287,6 +282,7 @@ export default defineComponent({
|
|
|
287
282
|
validations,
|
|
288
283
|
errorEmailMessage,
|
|
289
284
|
errorPasswordMessage,
|
|
285
|
+
apiErrorMessage,
|
|
290
286
|
forgottenPassword,
|
|
291
287
|
emailResetPassword,
|
|
292
288
|
isReset,
|
|
@@ -336,17 +332,21 @@ export default defineComponent({
|
|
|
336
332
|
|
|
337
333
|
.title {
|
|
338
334
|
margin-top: 120px;
|
|
339
|
-
font-size:
|
|
335
|
+
font-size: 24px;
|
|
340
336
|
font-weight: 700;
|
|
341
|
-
|
|
342
337
|
color: #41c4ff;
|
|
343
338
|
line-height: normal;
|
|
344
339
|
z-index: 1;
|
|
345
340
|
}
|
|
346
341
|
|
|
347
|
-
|
|
342
|
+
.login-page .q-field__control-container {
|
|
343
|
+
padding: 4px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.login-page div.q-field__control {
|
|
348
347
|
padding: 0;
|
|
349
348
|
border: 1px solid #d5d7da;
|
|
349
|
+
height: 55px;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
.q-field--with-bottom {
|
|
@@ -397,8 +397,12 @@ div.q-field__control {
|
|
|
397
397
|
gap: 6px;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
.login-page .q-
|
|
401
|
-
|
|
400
|
+
.login-page .q-field--error .q-field__bottom {
|
|
401
|
+
color: #EF476F;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.login-page .q-field__bottom {
|
|
405
|
+
padding: 4px 0px;
|
|
402
406
|
}
|
|
403
407
|
|
|
404
408
|
.login-page .q-field--error .q-field__append .q-icon:not(.cursor-pointer) {
|
|
@@ -432,7 +436,7 @@ div.q-field__control {
|
|
|
432
436
|
@media (max-width: 389px) {
|
|
433
437
|
.title {
|
|
434
438
|
margin-top: 80px;
|
|
435
|
-
font-size:
|
|
439
|
+
font-size: 24px;
|
|
436
440
|
margin-left: 16px;
|
|
437
441
|
margin-right: 16px;
|
|
438
442
|
}
|
package/src/composables/auth.ts
CHANGED
|
@@ -65,9 +65,11 @@ export function useAuth() {
|
|
|
65
65
|
const emailResetPassword = ref("")
|
|
66
66
|
const errorEmailMessage = ref("")
|
|
67
67
|
const errorPasswordMessage = ref("")
|
|
68
|
+
const apiErrorMessage = ref("")
|
|
68
69
|
const validations = ref({
|
|
69
70
|
email: [
|
|
70
71
|
(val: string) => {
|
|
72
|
+
apiErrorMessage.value = ""
|
|
71
73
|
errorEmailMessage.value = !!val ? "" : t("auth.emailPresenceError")
|
|
72
74
|
return !!val || t("auth.emailPresenceError")
|
|
73
75
|
},
|
|
@@ -80,6 +82,7 @@ export function useAuth() {
|
|
|
80
82
|
],
|
|
81
83
|
password: [
|
|
82
84
|
(val: string) => {
|
|
85
|
+
apiErrorMessage.value = ""
|
|
83
86
|
errorPasswordMessage.value = !!val
|
|
84
87
|
? ""
|
|
85
88
|
: t("auth.passwordPresenceError")
|
|
@@ -105,6 +108,8 @@ export function useAuth() {
|
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
const onSubmit = async (provider = "SoWell") => {
|
|
111
|
+
apiErrorMessage.value = ""
|
|
112
|
+
|
|
108
113
|
if (provider === "SoWell") {
|
|
109
114
|
loading.value = true
|
|
110
115
|
}
|
|
@@ -139,9 +144,15 @@ export function useAuth() {
|
|
|
139
144
|
if (requestedRoles) options.headers["x-requested-roles"] = requestedRoles
|
|
140
145
|
|
|
141
146
|
try {
|
|
142
|
-
await authState.signin(data, options)
|
|
147
|
+
const token = await authState.signin(data, options)
|
|
143
148
|
loading.value = false
|
|
144
149
|
msalLoading.value = false
|
|
150
|
+
|
|
151
|
+
if (!token) {
|
|
152
|
+
apiErrorMessage.value = t("auth.loginFailed")
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
145
156
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
157
|
// @ts-ignore
|
|
147
158
|
if (!window.Cypress) {
|
|
@@ -152,9 +163,23 @@ export function useAuth() {
|
|
|
152
163
|
}
|
|
153
164
|
push(LOCAL_SUCCESS_REDIRECTION_ROUTE)
|
|
154
165
|
} catch (err) {
|
|
155
|
-
console.error("onSubmit", err)
|
|
156
166
|
loading.value = false
|
|
157
167
|
msalLoading.value = false
|
|
168
|
+
|
|
169
|
+
if (err && typeof err === "object" && "response" in err) {
|
|
170
|
+
const axiosError = err as any
|
|
171
|
+
if (axiosError.response?.status === 401) {
|
|
172
|
+
apiErrorMessage.value = t("auth.loginFailed")
|
|
173
|
+
} else if (axiosError.response?.status === 403) {
|
|
174
|
+
apiErrorMessage.value = t("auth.403")
|
|
175
|
+
} else if (axiosError.response?.status === 404) {
|
|
176
|
+
apiErrorMessage.value = t("auth.404")
|
|
177
|
+
} else if (axiosError.code === "ERR_NETWORK") {
|
|
178
|
+
apiErrorMessage.value = t("auth.offlineMessage")
|
|
179
|
+
} else {
|
|
180
|
+
apiErrorMessage.value = t("auth.loginFailed")
|
|
181
|
+
}
|
|
182
|
+
}
|
|
158
183
|
}
|
|
159
184
|
}
|
|
160
185
|
|
|
@@ -225,6 +250,7 @@ export function useAuth() {
|
|
|
225
250
|
validations,
|
|
226
251
|
errorEmailMessage,
|
|
227
252
|
errorPasswordMessage,
|
|
253
|
+
apiErrorMessage,
|
|
228
254
|
forgottenPassword,
|
|
229
255
|
emailResetPassword,
|
|
230
256
|
isReset,
|