@sowell/quasar-app-extension-auth 1.10.1 → 1.11.0

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,16 +1,16 @@
1
1
  {
2
2
  "name": "@sowell/quasar-app-extension-auth",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
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",
7
7
  "scripts": {
8
- "lint": "cd dev && eslint --ext .js,.ts,.vue ./",
8
+ "lint": "eslint --ext .js,.ts,.vue ./",
9
9
  "dev": "cd dev && quasar dev",
10
10
  "dep": "cd dev && yarn",
11
11
  "test:link": "cd dev && yarn test:link",
12
12
  "test:browser": "cd dev && yarn test:browser",
13
- "test": "cd dev && yarn test"
13
+ "test": "vitest run"
14
14
  },
15
15
  "keywords": [],
16
16
  "author": "SoWell SAS",
@@ -34,7 +34,10 @@
34
34
  "eslint-plugin-vue": "^7.0.0",
35
35
  "jwt-decode": "^3.1.2",
36
36
  "quasar": "^2.8.4",
37
- "typescript": "^4.4.2"
37
+ "typescript": "^4.4.2",
38
+ "vitest": "^4.1.11",
39
+ "vue": "^3.2.0",
40
+ "vue-i18n": "^9"
38
41
  },
39
42
  "directories": {
40
43
  "test": "test"
@@ -124,6 +124,9 @@ export function useMagicLink() {
124
124
  }
125
125
 
126
126
  const requestChannels = async () => {
127
+ // Quasar's `loading` does not disable the button: Enter would resubmit and send
128
+ // a second e-mail, invalidating the first link (the API replaces the token).
129
+ if (isLoading.value) return
127
130
  apiErrorMessage.value = ""
128
131
  if (!validateEmail()) return
129
132
  isLoading.value = true
@@ -138,14 +141,21 @@ export function useMagicLink() {
138
141
  channels.value = offered.length ? offered : ["email"]
139
142
  channelTargets.value = targets
140
143
  selectedChannel.value = "email"
144
+ // Nothing to choose when only e-mail is offered (user without phone, or an
145
+ // app restricted to e-mail): send the link straight away.
146
+ if (channels.value.length === 1 && channels.value[0] === "email") {
147
+ await sendMagicLink("email")
148
+ return
149
+ }
141
150
  step.value = "channel"
142
151
  } catch (error) {
143
152
  const axiosError = error as AxiosError
144
153
  if (axiosError.response?.status === 403) {
145
- // Backend check: ENV["COMPANY_RESET_PASSWORD_FORBIDDEN"] vs user.company_id,
146
- // rescued as Rescueable::Forbidden with i18n key errors.magiclink.forbidden.
147
- // No pre-flight signal exists (no Company.config field, nothing on /me) - the
148
- // front can only ever find out by attempting the call, hence no button hiding.
154
+ // Backend check: the user's company (or its master/slaves) has
155
+ // `no_password_reset` set, rescued as Rescueable::Forbidden with i18n key
156
+ // errors.magiclink.forbidden. No pre-flight signal exists on the front, so
157
+ // it only finds out by attempting the call, hence no button hiding. The
158
+ // same 403 can come from the automatic send in requestChannels.
149
159
  restricted.value = true
150
160
  restrictedMessage.value = readApiError(error) || ""
151
161
  } else if (axiosError.response?.status === 404) {