@sowell/quasar-app-extension-auth 1.4.1 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sowell/quasar-app-extension-auth",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "A Quasar app extension to manage Authentication",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/sowell-ai/quasar.extension.auth",
@@ -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: 20px" class="q-mx-lg input-container">
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>
@@ -79,7 +79,7 @@
79
79
  text-color="white"
80
80
  :loading="loading"
81
81
  type="submit"
82
- class="full-width q-mt-md login-button"
82
+ class="full-width q-mt-lg login-button"
83
83
  :disable="isSubmitBtnDisabled()">
84
84
  <div style="font-weight: 500; font-size: 18px">
85
85
  {{ $t("auth.login") }}
@@ -88,7 +88,7 @@
88
88
  </div>
89
89
  <div
90
90
  class="forgot-password-link self-start"
91
- style="font-weight: 500; margin: 12px 0"
91
+ style="font-weight: 500; margin: 12px 0; text-decoration: underline;"
92
92
  @click="forgottenPassword = true"
93
93
  data-testid="ask-password-change-btn"
94
94
  data-cy="forgot-password">
@@ -127,19 +127,10 @@
127
127
  </div>
128
128
  <div class="error-message-container">
129
129
  <div
130
- v-if="errorEmailMessage || errorPasswordMessage"
130
+ v-if="apiErrorMessage"
131
131
  class="text-red column justify-center error_input">
132
132
  <ErrorMessage
133
- v-if="errorEmailMessage && !errorPasswordMessage"
134
- :message="errorEmailMessage"
135
- class="error-message-item" />
136
- <ErrorMessage
137
- v-if="errorPasswordMessage && !errorEmailMessage"
138
- :message="errorPasswordMessage"
139
- class="error-message-item" />
140
- <ErrorMessage
141
- v-if="errorEmailMessage && errorPasswordMessage"
142
- :message="$t('auth.emailOrPasswordIncorrect')"
133
+ :message="apiErrorMessage"
143
134
  class="error-message-item" />
144
135
  </div>
145
136
  <div v-else class="error-placeholder q-mt-sm"></div>
@@ -184,7 +175,7 @@
184
175
  </div>
185
176
  </div>
186
177
  <div class="row justify-between full-width items-center q-px-md q-mt-auto">
187
- <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;">
188
179
  {{ $t("common.privacyPolicy") }}
189
180
  </div>
190
181
  <div class="row justify-end footer-text">
@@ -216,6 +207,7 @@ export default defineComponent({
216
207
  validations,
217
208
  errorEmailMessage,
218
209
  errorPasswordMessage,
210
+ apiErrorMessage,
219
211
  forgottenPassword,
220
212
  emailResetPassword,
221
213
  isReset,
@@ -290,6 +282,7 @@ export default defineComponent({
290
282
  validations,
291
283
  errorEmailMessage,
292
284
  errorPasswordMessage,
285
+ apiErrorMessage,
293
286
  forgottenPassword,
294
287
  emailResetPassword,
295
288
  isReset,
@@ -339,9 +332,8 @@ export default defineComponent({
339
332
 
340
333
  .title {
341
334
  margin-top: 120px;
342
- font-size: 36px;
335
+ font-size: 24px;
343
336
  font-weight: 700;
344
-
345
337
  color: #41c4ff;
346
338
  line-height: normal;
347
339
  z-index: 1;
@@ -405,8 +397,12 @@ export default defineComponent({
405
397
  gap: 6px;
406
398
  }
407
399
 
408
- .login-page .q-field__messages {
409
- display: none;
400
+ .login-page .q-field--error .q-field__bottom {
401
+ color: #EF476F;
402
+ }
403
+
404
+ .login-page .q-field__bottom {
405
+ padding: 4px 0px;
410
406
  }
411
407
 
412
408
  .login-page .q-field--error .q-field__append .q-icon:not(.cursor-pointer) {
@@ -440,7 +436,7 @@ export default defineComponent({
440
436
  @media (max-width: 389px) {
441
437
  .title {
442
438
  margin-top: 80px;
443
- font-size: 28px;
439
+ font-size: 24px;
444
440
  margin-left: 16px;
445
441
  margin-right: 16px;
446
442
  }
@@ -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,