@sowell/quasar-app-extension-auth 1.4.1 → 1.4.3

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.3",
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",
@@ -40,7 +40,8 @@
40
40
  "test": "test"
41
41
  },
42
42
  "dependencies": {
43
- "@capacitor/core": "^4.6.2",
43
+ "@capacitor/core": "^7.0.0",
44
+ "@capacitor/inappbrowser": "^2.3.1",
44
45
  "@quasar/extras": "^1.15.2",
45
46
  "axios": "^0.21.1",
46
47
  "buffer": "^6.0.3",
@@ -22,7 +22,7 @@
22
22
  class="q-mb-sm"
23
23
  style="font-size: 34px; font-weight: 600; line-height: 40px"
24
24
  >
25
- {{ $t("auth.forgottenPassword") }}
25
+ <span v-html="$t('auth.forgottenPassword').replace(/ (?!.* )/, '&nbsp;')" />
26
26
  </div>
27
27
  <div
28
28
  class="text-subtitle1 q-mt-sm q-mb-lg"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <q-layout
3
3
  class="column justify-start items-center q-pb-lg bg-white"
4
- style="min-height: 100vh; max-width: 100vw; overflow-x: hidden">
4
+ style="min-height: 90vh; max-width: 100vw; overflow-x: hidden">
5
5
  <div class="background-logo-container">
6
6
  <img
7
7
  src="../../assets/Background-logo.svg"
@@ -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>
@@ -28,7 +28,7 @@
28
28
  type="email"
29
29
  borderless
30
30
  :rules="validations['email']"
31
- placeholder="Yourname@gmail.com"
31
+ placeholder="yourname@gmail.com"
32
32
  lazy-rules
33
33
  class="q-px-none q-mt-sm"
34
34
  :class="{ 'input-error': errorEmailMessage }"
@@ -47,7 +47,6 @@
47
47
  v-model="password"
48
48
  :type="showPassword ? 'text' : 'password'"
49
49
  :rules="validations['password']"
50
- placeholder="********"
51
50
  lazy-rules
52
51
  borderless
53
52
  class="q-px-none q-mt-sm"
@@ -79,7 +78,7 @@
79
78
  text-color="white"
80
79
  :loading="loading"
81
80
  type="submit"
82
- class="full-width q-mt-md login-button"
81
+ class="full-width q-mt-lg login-button"
83
82
  :disable="isSubmitBtnDisabled()">
84
83
  <div style="font-weight: 500; font-size: 18px">
85
84
  {{ $t("auth.login") }}
@@ -88,7 +87,11 @@
88
87
  </div>
89
88
  <div
90
89
  class="forgot-password-link self-start"
91
- style="font-weight: 500; margin: 12px 0"
90
+ style="
91
+ font-weight: 500;
92
+ margin: 12px 0;
93
+ text-decoration: underline;
94
+ "
92
95
  @click="forgottenPassword = true"
93
96
  data-testid="ask-password-change-btn"
94
97
  data-cy="forgot-password">
@@ -127,19 +130,10 @@
127
130
  </div>
128
131
  <div class="error-message-container">
129
132
  <div
130
- v-if="errorEmailMessage || errorPasswordMessage"
133
+ v-if="apiErrorMessage"
131
134
  class="text-red column justify-center error_input">
132
135
  <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')"
136
+ :message="apiErrorMessage"
143
137
  class="error-message-item" />
144
138
  </div>
145
139
  <div v-else class="error-placeholder q-mt-sm"></div>
@@ -183,10 +177,16 @@
183
177
  </q-dialog>
184
178
  </div>
185
179
  </div>
186
- <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">
188
- {{ $t("common.privacyPolicy") }}
189
- </div>
180
+ <div
181
+ class="row justify-between full-width items-center q-px-md q-mt-auto absolute-bottom">
182
+ <q-btn
183
+ flat
184
+ no-caps
185
+ class="footer-text q-px-none"
186
+ :ripple="false"
187
+ @click="goToPrivacyPolicy"
188
+ :label="$t('common.privacyPolicy')"
189
+ style="text-decoration: underline" />
190
190
  <div class="row justify-end footer-text">
191
191
  {{ `VERSION ${appVersion.versionNumber}` }}
192
192
  </div>
@@ -196,6 +196,10 @@
196
196
 
197
197
  <script lang="ts">
198
198
  import { defineComponent, reactive, onMounted, computed } from "vue"
199
+ import {
200
+ InAppBrowser,
201
+ DefaultSystemBrowserOptions
202
+ } from "@capacitor/inappbrowser"
199
203
  import * as packageInfo from "app/package.json"
200
204
  import SendEmail from "../dialogs/SendEmail.vue"
201
205
  import SowellMessage from "../dialogs/Message.vue"
@@ -216,6 +220,7 @@ export default defineComponent({
216
220
  validations,
217
221
  errorEmailMessage,
218
222
  errorPasswordMessage,
223
+ apiErrorMessage,
219
224
  forgottenPassword,
220
225
  emailResetPassword,
221
226
  isReset,
@@ -270,8 +275,11 @@ export default defineComponent({
270
275
  }
271
276
  }
272
277
 
273
- const goToPrivacyPolicy = () => {
274
- window.open("https://sowell.app/privacy-policy-sowell/", "_blank")
278
+ const goToPrivacyPolicy = async () => {
279
+ await InAppBrowser.openInSystemBrowser({
280
+ url: "https://sowell.app/privacy-policy-sowell/",
281
+ options: DefaultSystemBrowserOptions
282
+ })
275
283
  }
276
284
 
277
285
  onMounted(() => {
@@ -290,6 +298,7 @@ export default defineComponent({
290
298
  validations,
291
299
  errorEmailMessage,
292
300
  errorPasswordMessage,
301
+ apiErrorMessage,
293
302
  forgottenPassword,
294
303
  emailResetPassword,
295
304
  isReset,
@@ -334,14 +343,13 @@ export default defineComponent({
334
343
  }
335
344
 
336
345
  .sowell-logo {
337
- padding: 40px 0 0 20px;
346
+ padding: 34px 0 0 20px;
338
347
  }
339
348
 
340
349
  .title {
341
350
  margin-top: 120px;
342
- font-size: 36px;
351
+ font-size: 24px;
343
352
  font-weight: 700;
344
-
345
353
  color: #41c4ff;
346
354
  line-height: normal;
347
355
  z-index: 1;
@@ -405,8 +413,12 @@ export default defineComponent({
405
413
  gap: 6px;
406
414
  }
407
415
 
408
- .login-page .q-field__messages {
409
- display: none;
416
+ .login-page .q-field--error .q-field__bottom {
417
+ color: #ef476f;
418
+ }
419
+
420
+ .login-page .q-field__bottom {
421
+ padding: 4px 0px;
410
422
  }
411
423
 
412
424
  .login-page .q-field--error .q-field__append .q-icon:not(.cursor-pointer) {
@@ -440,7 +452,7 @@ export default defineComponent({
440
452
  @media (max-width: 389px) {
441
453
  .title {
442
454
  margin-top: 80px;
443
- font-size: 28px;
455
+ font-size: 24px;
444
456
  margin-left: 16px;
445
457
  margin-right: 16px;
446
458
  }
@@ -449,7 +461,8 @@ export default defineComponent({
449
461
  padding: 12px 0 0 16px;
450
462
  }
451
463
 
452
- .login-page .input-container, .login-page .button-container {
464
+ .login-page .input-container,
465
+ .login-page .button-container {
453
466
  margin-left: 16px !important;
454
467
  margin-right: 16px !important;
455
468
  }
@@ -465,12 +478,12 @@ export default defineComponent({
465
478
  .login-button div {
466
479
  font-size: 14px !important;
467
480
  }
468
-
481
+
469
482
  .error_input {
470
483
  min-height: 50px;
471
484
  padding: 4px 12px;
472
485
  }
473
-
486
+
474
487
  .error-placeholder {
475
488
  min-height: 25px;
476
489
  }
@@ -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,