@sowell/quasar-app-extension-auth 1.8.4 → 1.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sowell/quasar-app-extension-auth",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
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",
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="82" height="82" viewBox="0 0 82 82" fill="none">
2
+ <path d="M20.467 13.2638C20.467 13.2638 32.783 22.7041 51.5063 5.05236C68.1346 -10.6241 81.7117 14.1097 81.8067 25.9544C81.9298 41.298 65.1784 53.5748 73.3078 63.6526C81.4372 73.7304 57.1861 90.3722 44.116 75.9698C27.8572 58.0538 23.4525 72.6106 14.185 72.6106C7.53374 72.6106 -6.12216 55.9168 3.09953 43.4971C10.8594 33.0461 6.6273 29.5776 4.57785 25.9544C1.62159 20.7288 8.64242 6.54534 20.467 13.2638Z" fill="#FFEFCF"/>
3
+ <path d="M63.1242 56.9728L44.1383 21.3586C42.7926 18.8336 39.2078 18.8336 37.861 21.3586L18.8762 56.9728C18.584 57.5209 18.4375 58.1363 18.4511 58.7587C18.4646 59.3811 18.6376 59.9894 18.9533 60.5241C19.269 61.0588 19.7165 61.5017 20.2522 61.8095C20.788 62.1174 21.3935 62.2797 22.0099 62.2806H59.9849C60.6017 62.2807 61.208 62.1191 61.7445 61.8116C62.281 61.5042 62.7293 61.0614 63.0457 60.5265C63.362 59.9916 63.5355 59.383 63.5493 58.7601C63.5631 58.1372 63.4166 57.5214 63.1242 56.9728V56.9728ZM41.0002 56.7669C40.5595 56.7669 40.1288 56.6349 39.7624 56.3876C39.396 56.1403 39.1104 55.7888 38.9418 55.3776C38.7732 54.9664 38.729 54.5139 38.815 54.0773C38.901 53.6408 39.1132 53.2397 39.4248 52.925C39.7364 52.6103 40.1333 52.3959 40.5655 52.3091C40.9977 52.2223 41.4457 52.2668 41.8528 52.4372C42.2599 52.6075 42.6079 52.896 42.8527 53.266C43.0975 53.6361 43.2282 54.0712 43.2282 54.5164C43.2282 54.8119 43.1706 55.1045 43.0586 55.3776C42.9466 55.6506 42.7825 55.8987 42.5756 56.1077C42.3687 56.3167 42.1231 56.4824 41.8528 56.5955C41.5825 56.7086 41.2928 56.7669 41.0002 56.7669ZM43.4198 34.1325L42.7804 47.8605C42.7804 48.338 42.5926 48.7959 42.2583 49.1336C41.924 49.4712 41.4707 49.6609 40.998 49.6609C40.5252 49.6609 40.0719 49.4712 39.7376 49.1336C39.4034 48.7959 39.2156 48.338 39.2156 47.8605L38.5761 34.1381C38.5618 33.8102 38.6129 33.4827 38.7265 33.1752C38.8401 32.8677 39.0138 32.5864 39.2373 32.3481C39.4608 32.1099 39.7295 31.9195 40.0274 31.7884C40.3253 31.6573 40.6463 31.5881 40.9712 31.5849H40.9946C41.3218 31.5847 41.6456 31.6515 41.9465 31.7812C42.2474 31.9109 42.5191 32.1009 42.7453 32.3396C42.9716 32.5783 43.1476 32.8608 43.2627 33.1701C43.3779 33.4794 43.4298 33.8091 43.4153 34.1392L43.4198 34.1325Z" fill="#FFBD3D"/>
4
+ </svg>
@@ -12,9 +12,13 @@
12
12
  src="../../assets/success.svg"
13
13
  style="width: 100px; height: 80px" />
14
14
  <img
15
- v-if="emailNotSend"
15
+ v-if="emailNotSend && !isForbidden"
16
16
  src="../../assets/error.svg"
17
17
  style="width: 100px; height: 80px" />
18
+ <img
19
+ v-if="isForbidden"
20
+ src="../../assets/restricted.svg"
21
+ style="width: 82px; height: 82px" />
18
22
  </q-card-section>
19
23
 
20
24
  <q-card-section class="q-pt-none q-pl-lg q-pr-lg">
@@ -30,7 +34,27 @@
30
34
  data-testid="message-dialog"
31
35
  class="text-subtitle1 q-mt-sm text-center"
32
36
  style="font-size: 16px; font-weight: 400">
33
- {{ messageSubtitle }}
37
+ {{ messageSubtitleParts.before
38
+ }}<strong>{{ messageSubtitleParts.bold }}</strong
39
+ >{{ messageSubtitleParts.after }}
40
+ </div>
41
+ <div v-if="isForbidden" class="forbidden-sso-section">
42
+ <div class="forbidden-sso-label">{{ $t("auth.continueWith") }}</div>
43
+ <q-btn
44
+ data-testid="forbidden-sso-btn"
45
+ data-cy="submit-sso-login"
46
+ unelevated
47
+ no-caps
48
+ dense
49
+ :loading="msalLoading"
50
+ :disable="msalLoading"
51
+ class="forbidden-sso-button"
52
+ @click="onMsalAuth">
53
+ <img
54
+ src="../../assets/logo-microsoft.svg"
55
+ class="forbidden-sso-icon" />
56
+ {{ $t("auth.microsoft") }}
57
+ </q-btn>
34
58
  </div>
35
59
  <div
36
60
  class="q-mt-sm text-center q-mb-xl"
@@ -73,6 +97,8 @@
73
97
  import { defineComponent, computed } from "vue"
74
98
  import { useI18n } from "vue-i18n"
75
99
 
100
+ const FORBIDDEN_MESSAGE_BOLD_KEYWORD = "Microsoft"
101
+
76
102
  export default defineComponent({
77
103
  props: {
78
104
  emailResetPassword: {
@@ -84,17 +110,22 @@ export default defineComponent({
84
110
  loading: {
85
111
  type: Boolean
86
112
  },
113
+ msalLoading: {
114
+ type: Boolean
115
+ },
87
116
  passwordUpdated: {
88
117
  type: Boolean
89
118
  }
90
119
  },
91
- emit: ["retypeEmail", "goToLoginPage", "close"],
120
+ emit: ["retypeEmail", "goToLoginPage", "close", "msalAuth"],
92
121
  setup(props: any, { emit }: any) {
93
122
  const { t } = useI18n()
94
123
 
124
+ const isForbidden = computed(() => props.sendEmailCode === 403)
125
+
95
126
  const messageSubtitle = computed(() => {
96
127
  if (props.sendEmailCode === 403) {
97
- return t("auth.forbidden.subtitle")
128
+ return t("auth.restrictedDescription")
98
129
  }
99
130
  return props.sendEmailCode === 200
100
131
  ? t("auth.emailSent")
@@ -104,7 +135,7 @@ export default defineComponent({
104
135
  })
105
136
  const messageTitle = computed(() => {
106
137
  if (props.sendEmailCode === 403) {
107
- return t("auth.forbidden.title")
138
+ return t("auth.restrictedTitle")
108
139
  }
109
140
  return props.sendEmailCode === 200
110
141
  ? t("auth.emailVerification")
@@ -113,6 +144,23 @@ export default defineComponent({
113
144
  : t("auth.passwordChanged")
114
145
  })
115
146
 
147
+ // The forbidden message names "Microsoft" - it is emphasised the same way
148
+ // as on the magic link restricted screen.
149
+ const messageSubtitleParts = computed(() => {
150
+ const message = messageSubtitle.value
151
+ const keywordIndex = message.indexOf(FORBIDDEN_MESSAGE_BOLD_KEYWORD)
152
+ if (!isForbidden.value || keywordIndex === -1) {
153
+ return { before: message, bold: "", after: "" }
154
+ }
155
+ return {
156
+ before: message.slice(0, keywordIndex),
157
+ bold: FORBIDDEN_MESSAGE_BOLD_KEYWORD,
158
+ after: message.slice(
159
+ keywordIndex + FORBIDDEN_MESSAGE_BOLD_KEYWORD.length
160
+ )
161
+ }
162
+ })
163
+
116
164
  const emailNotSend = computed(
117
165
  () => props.sendEmailCode !== 200 && !props.passwordUpdated
118
166
  )
@@ -124,6 +172,10 @@ export default defineComponent({
124
172
  emit("retypeEmail")
125
173
  }
126
174
 
175
+ const onMsalAuth = () => {
176
+ emit("msalAuth")
177
+ }
178
+
127
179
  const handlePasswordUpdate = () => {
128
180
  if (props.passwordUpdated) {
129
181
  emit("goToLoginPage")
@@ -134,12 +186,49 @@ export default defineComponent({
134
186
 
135
187
  return {
136
188
  messageSubtitle,
189
+ messageSubtitleParts,
137
190
  messageTitle,
138
191
  emailNotSend,
139
192
  emailSended,
193
+ isForbidden,
140
194
  handlePasswordUpdate,
141
- retypeEmail
195
+ retypeEmail,
196
+ onMsalAuth
142
197
  }
143
198
  }
144
199
  })
145
200
  </script>
201
+
202
+ <style scoped lang="scss">
203
+ .forbidden-sso-section {
204
+ margin-top: 24px;
205
+ text-align: center;
206
+ }
207
+
208
+ .forbidden-sso-label {
209
+ font-size: 15px;
210
+ font-weight: 600;
211
+ color: #112240;
212
+ margin-bottom: 12px;
213
+ }
214
+
215
+ .forbidden-sso-button {
216
+ width: 180px;
217
+ height: 36px;
218
+ border-radius: 8px;
219
+ background: #ebeeef;
220
+ font-size: 12px;
221
+ font-weight: 600;
222
+ color: #112240;
223
+ }
224
+
225
+ .forbidden-sso-button:hover {
226
+ background: #e0e5e7;
227
+ }
228
+
229
+ .forbidden-sso-icon {
230
+ width: 16px;
231
+ height: 16px;
232
+ margin-right: 8px;
233
+ }
234
+ </style>
@@ -29,7 +29,8 @@
29
29
  class="text-subtitle1 q-mt-sm text-center text-dark"
30
30
  data-testid="message-dialog"
31
31
  >
32
- {{ content }}
32
+ {{ contentParts.before
33
+ }}<strong>{{ contentParts.bold }}</strong>{{ contentParts.after }}
33
34
  </div>
34
35
  </q-card-section>
35
36
  <q-card-actions class="row full-width justify-center q-mb-lg">
@@ -56,6 +57,7 @@ import { defineComponent, computed } from "vue";
56
57
  import userNotFound from "../../assets/User-not-found.svg";
57
58
  import passwordUpdated from "../../assets/Ok-illustration.svg";
58
59
  import emailVerification from "../../assets/Email-sent.svg";
60
+ import restricted from "../../assets/restricted.svg";
59
61
  import { ionCloseOutline } from "@quasar/extras/ionicons-v5";
60
62
 
61
63
  export default defineComponent({
@@ -66,6 +68,9 @@ export default defineComponent({
66
68
  image: { type: String, required: true },
67
69
  passwordUpdated: { type: Boolean },
68
70
  isOtp: { type: Boolean, default: false, required: false },
71
+ // Emphasises one word of `content` - used to bold "Microsoft" on the
72
+ // restricted / SSO-only message, like the magic link screens do.
73
+ boldKeyword: { type: String, default: "", required: false },
69
74
  },
70
75
  emit: ["goToLoginPage", "close"],
71
76
  setup(props: any) {
@@ -79,12 +84,29 @@ export default defineComponent({
79
84
 
80
85
  case "emailVerification":
81
86
  return emailVerification;
87
+
88
+ case "restricted":
89
+ return restricted;
82
90
  default:
83
91
  return null
84
92
  }
85
93
  })
86
94
 
87
- return { imageValue, icons: { ionCloseOutline } };
95
+ const contentParts = computed(() => {
96
+ const content = props.content as string;
97
+ const keyword = props.boldKeyword as string;
98
+ const keywordIndex = keyword ? content.indexOf(keyword) : -1;
99
+ if (keywordIndex === -1) {
100
+ return { before: content, bold: "", after: "" };
101
+ }
102
+ return {
103
+ before: content.slice(0, keywordIndex),
104
+ bold: keyword,
105
+ after: content.slice(keywordIndex + keyword.length),
106
+ };
107
+ });
108
+
109
+ return { imageValue, contentParts, icons: { ionCloseOutline } };
88
110
  },
89
111
  });
90
112
  </script>
@@ -114,6 +114,7 @@
114
114
  :content="infoDialog.content"
115
115
  :image="infoDialog.image"
116
116
  :isOtp="true"
117
+ :boldKeyword="infoDialog.isForbidden ? 'Microsoft' : ''"
117
118
  >
118
119
  <q-btn
119
120
  v-if="requestedOtp"
@@ -134,6 +135,7 @@
134
135
 
135
136
  <script lang="ts">
136
137
  import { defineComponent, ref, computed } from "vue"
138
+ import { AxiosError } from "axios"
137
139
  import { useI18n } from "vue-i18n"
138
140
  import isEmail from "validator/es/lib/isEmail"
139
141
  import { useAuthState } from "../../injects"
@@ -180,7 +182,8 @@ export default defineComponent({
180
182
  const infoDialog = ref({
181
183
  title: "",
182
184
  content: "",
183
- image: ""
185
+ image: "",
186
+ isForbidden: false
184
187
  })
185
188
 
186
189
  const submitBtnDisabled = computed(
@@ -204,6 +207,7 @@ export default defineComponent({
204
207
  await authState.resetPassword(data).then(() => {
205
208
  localStorage.setItem("emailResetPassword", email)
206
209
  infoDialog.value = {
210
+ isForbidden: false,
207
211
  title: t("auth.mailVerificationTitle"),
208
212
  content:
209
213
  IS_OTP.toLowerCase() === "y"
@@ -215,13 +219,25 @@ export default defineComponent({
215
219
  isNotification.value = true
216
220
  requestedOtp.value = true
217
221
  })
218
- } catch {
222
+ } catch (error) {
219
223
  requestedOtp.value = false
220
- infoDialog.value = {
221
- title: t("auth.userNotFoundTitle"),
222
- content: t("auth.userNotFoundSubtitle"),
223
- image: "userNotFound"
224
- }
224
+ // NOTE: 403 is returned when the company does not allow password reset
225
+ // (SSO-only account). The admin interface has no SSO entry point, so we
226
+ // only tell the user to reach out to their organisation.
227
+ infoDialog.value =
228
+ (error as AxiosError).response?.status === 403
229
+ ? {
230
+ isForbidden: true,
231
+ title: t("auth.restrictedTitle"),
232
+ content: t("auth.restrictedDescription"),
233
+ image: "restricted"
234
+ }
235
+ : {
236
+ isForbidden: false,
237
+ title: t("auth.userNotFoundTitle"),
238
+ content: t("auth.userNotFoundSubtitle"),
239
+ image: "userNotFound"
240
+ }
225
241
  isNotification.value = true
226
242
  }
227
243
  }
@@ -150,7 +150,9 @@
150
150
  :emailResetPassword="emailResetPassword"
151
151
  :sendEmailCode="sendEmailCode"
152
152
  :loading="loading"
153
- @retypeEmail="retypeEmail"
153
+ :msalLoading="msalLoading"
154
+ @retypeEmail="retypeEmail"
155
+ @msalAuth="msalAuth"
154
156
  @close="() => isReset= false"/>
155
157
  </q-dialog>
156
158
  </div>
@@ -169,6 +171,7 @@
169
171
 
170
172
  <script lang="ts">
171
173
  import { defineComponent, reactive, onMounted } from "vue"
174
+ import { AxiosError } from "axios"
172
175
  import * as packageInfo from "app/package.json"
173
176
 
174
177
  import SendEmail from "../dialogs/SendEmail.vue"
@@ -220,8 +223,11 @@ export default defineComponent({
220
223
  sendEmailCode.value = 200
221
224
  isReset.value = true
222
225
  })
223
- } catch {
224
- sendEmailCode.value = 404
226
+ } catch (error) {
227
+ // NOTE: 403 is returned when the company does not allow password reset
228
+ // (SSO-only account) - the dialog then offers the Microsoft login instead.
229
+ sendEmailCode.value =
230
+ (error as AxiosError).response?.status === 403 ? 403 : 404
225
231
  isReset.value = true
226
232
  }
227
233
  }
@@ -169,7 +169,9 @@
169
169
  :emailResetPassword="emailResetPassword"
170
170
  :sendEmailCode="sendEmailCode"
171
171
  :loading="loading"
172
+ :msalLoading="msalLoading"
172
173
  @retypeEmail="retypeEmail"
174
+ @msalAuth="msalAuth"
173
175
  @close="() => (isReset = false)">
174
176
  <q-btn
175
177
  v-if="sendEmailCode === 200 && isOtp"
@@ -154,10 +154,39 @@
154
154
  :content="infoDialog.content"
155
155
  :image="infoDialog.image"
156
156
  :isOtp="isOtp"
157
+ :boldKeyword="infoDialog.isForbidden ? 'Microsoft' : ''"
157
158
  @close="() => (isNotification = false)">
159
+ <div v-if="infoDialog.isForbidden" class="column items-center">
160
+ <div class="forbidden-sso-label">{{ $t("auth.connectWith") }}</div>
161
+ <q-btn
162
+ data-testid="forbidden-sso-btn"
163
+ data-cy="submit-sso-login"
164
+ unelevated
165
+ no-caps
166
+ dense
167
+ :loading="msalLoading"
168
+ :disable="msalLoading"
169
+ class="forbidden-sso-button"
170
+ @click="msalAuth">
171
+ <img
172
+ src="../../assets/logo-microsoft.svg"
173
+ class="forbidden-sso-icon" />
174
+ {{ $t("auth.microsoft") }}
175
+ </q-btn>
176
+ <q-btn
177
+ data-testid="close-btn"
178
+ class="bg-white submitBtn q-mt-md"
179
+ unelevated
180
+ outline
181
+ no-caps
182
+ :label="$t('auth.close')"
183
+ color="primary"
184
+ @click="() => (isNotification = false)"
185
+ v-close-popup />
186
+ </div>
158
187
  <q-btn
159
188
  :data-testid="infoDialog.canGoNext ? 'next-btn' : 'close-btn'"
160
- v-if="isOtp"
189
+ v-else-if="isOtp"
161
190
  class="bg-white submitBtn"
162
191
  unelevated
163
192
  outline
@@ -226,7 +255,8 @@ export default defineComponent({
226
255
  const infoDialog = ref({
227
256
  title: "",
228
257
  content: "",
229
- image: ""
258
+ image: "",
259
+ isForbidden: false
230
260
  })
231
261
 
232
262
  const isOtp = computed(() => IS_OTP.toLowerCase() === "y")
@@ -252,6 +282,7 @@ export default defineComponent({
252
282
  localStorage.setItem("emailResetPassword", email)
253
283
  infoDialog.value = {
254
284
  canGoNext: true,
285
+ isForbidden: false,
255
286
  title: t("auth.mailVerificationTitle"),
256
287
  content:
257
288
  IS_OTP.toLowerCase() === "y"
@@ -267,13 +298,15 @@ export default defineComponent({
267
298
  // NOTE: 403 is returned when the user is not allowed to reset the password
268
299
  infoDialog.value = {
269
300
  canGoNext: false,
270
- title: t("auth.forbidden.title"),
271
- content: t("auth.forbidden.subtitle"),
272
- image: "userNotFound"
301
+ isForbidden: true,
302
+ title: t("auth.restrictedTitle"),
303
+ content: t("auth.restrictedDescription"),
304
+ image: "restricted"
273
305
  }
274
306
  } else {
275
307
  infoDialog.value = {
276
308
  canGoNext: false,
309
+ isForbidden: false,
277
310
  title: t("auth.userNotFoundTitle"),
278
311
  content: t("auth.userNotFoundSubtitle"),
279
312
  image: "userNotFound"
@@ -331,6 +364,34 @@ export default defineComponent({
331
364
  </script>
332
365
 
333
366
  <style scoped>
367
+ .forbidden-sso-label {
368
+ font-size: 15px;
369
+ font-weight: 600;
370
+ color: #112240;
371
+ margin-bottom: 12px;
372
+ }
373
+
374
+ .forbidden-sso-button {
375
+ width: 260px;
376
+ max-width: 100%;
377
+ height: 36px;
378
+ border-radius: 8.85px;
379
+ background: #ebeeef;
380
+ font-size: 15px;
381
+ font-weight: 600;
382
+ color: #112240;
383
+ }
384
+
385
+ .forbidden-sso-button:hover {
386
+ background: #e0e5e7;
387
+ }
388
+
389
+ .forbidden-sso-icon {
390
+ width: 18px;
391
+ height: 18px;
392
+ margin-right: 8px;
393
+ }
394
+
334
395
  .center {
335
396
  margin-top: -115px;
336
397
  }
@@ -49,6 +49,11 @@ export default {
49
49
  back: "Back",
50
50
  backToLoginFull: "Back to login",
51
51
  continueWith: "Or continue with",
52
+ connectWith: "Sign in with",
53
+ microsoft: "Microsoft",
54
+ restrictedTitle: "Reset unavailable",
55
+ restrictedDescription:
56
+ "Your account uses Microsoft login. You are not allowed to manage your password. To change it, contact your administrator.",
52
57
  emailOrPasswordIncorrect: "Email or password incorrect",
53
58
  magicLinkCheckSmsMessage: "Check your text messages",
54
59
  magicLinkWarningSms:
@@ -52,6 +52,11 @@ export default {
52
52
  back: "Retour",
53
53
  backToLoginFull: "Retour à la connexion",
54
54
  continueWith: "Ou continuer avec",
55
+ connectWith: "Se connecter avec",
56
+ microsoft: "Microsoft",
57
+ restrictedTitle: "Réinitialisation impossible",
58
+ restrictedDescription:
59
+ "Votre compte utilise la connexion Microsoft. La gestion de votre mot de passe vous est interdite. Pour le modifier, contactez votre administrateur.",
55
60
  emailOrPasswordIncorrect: "Email ou mot de passe incorrect",
56
61
  magicLinkCheckSmsMessage: "Vérifiez vos messages",
57
62
  magicLinkWarningSms: