@fy-/fws-vue 2.3.81 → 2.3.83

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.
@@ -139,29 +139,47 @@ async function userFlow(params: paramsType = { initial: false }) {
139
139
  },
140
140
  )) as UserFlow
141
141
  if (response.value?.result === 'success') {
142
+ // Check if inner data has error result
143
+ // @ts-expect-error - API can return error inside success response
144
+ if (response.value.data.result === 'error') {
145
+ // @ts-expect-error - Cast to APIResult for error handling
146
+ responseError.value = response.value.data as APIResult
147
+ if (responseError.value.param) {
148
+ fieldsError.value[responseError.value.param] = responseError.value.token
149
+ }
150
+ eventBus.emit('login-loading', false)
151
+ return
152
+ }
142
153
  if (response.value.data.complete === true && response.value.data.user) {
143
154
  store.setUser(response.value.data.user)
144
155
  const actualReturnTo = response.value.data.redirect
145
156
  ? response.value.data.redirect
146
157
  : returnTo.value
147
158
  session.value = null
148
- if (isExternalUrl(actualReturnTo)) {
149
- if (props.onSuccess) {
150
- await props.onSuccess()
159
+ try {
160
+ if (isExternalUrl(actualReturnTo)) {
161
+ if (props.onSuccess) {
162
+ await props.onSuccess()
163
+ }
164
+ else {
165
+ window.location.href = actualReturnTo
166
+ }
151
167
  }
152
168
  else {
153
- window.location.href = actualReturnTo
169
+ if (props.onSuccess) {
170
+ await props.onSuccess(actualReturnTo)
171
+ }
172
+ else {
173
+ const routeExists = router.resolve(actualReturnTo)
174
+ if (routeExists.matched.length !== 0) router.push(actualReturnTo)
175
+ else window.location.href = actualReturnTo
176
+ }
154
177
  }
155
178
  }
156
- else {
157
- if (props.onSuccess) {
158
- await props.onSuccess(actualReturnTo)
159
- }
160
- else {
161
- const routeExists = router.resolve(actualReturnTo)
162
- if (routeExists.matched.length !== 0) router.push(actualReturnTo)
163
- else window.location.href = actualReturnTo
164
- }
179
+ catch (error) {
180
+ console.error('Error in onSuccess callback:', error)
181
+ eventBus.emit('login-loading', false)
182
+ throw error
165
183
  }
166
184
  return
167
185
  }
@@ -209,6 +227,12 @@ async function userFlow(params: paramsType = { initial: false }) {
209
227
  eventBus.emit('login-loading', false)
210
228
  }
211
229
 
230
+ function handlePageRefresh() {
231
+ if (typeof window !== 'undefined') {
232
+ window.location.reload()
233
+ }
234
+ }
235
+
212
236
  onMounted(async () => {
213
237
  await userFlow({ initial: true })
214
238
  })
@@ -375,17 +399,42 @@ onMounted(async () => {
375
399
  </template>
376
400
  </template>
377
401
 
378
- <!-- Error message -->
402
+ <!-- Error message with token -->
379
403
  <div
380
404
  v-if="responseError && responseError.token"
381
405
  class="p-3 rounded-lg bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-300 text-sm font-medium"
382
406
  role="alert"
383
- v-html="$t(responseError.token)"
384
- />
407
+ >
408
+ <div v-html="$t(responseError.token)" />
409
+ <div v-if="responseError.message && responseError.message !== $t(responseError.token)" class="mt-2 text-xs opacity-90">
410
+ {{ responseError.message }}
411
+ </div>
412
+ </div>
413
+
414
+ <!-- General API error with refresh button -->
415
+ <div
416
+ v-if="responseError && !responseError.param && !responseError.token"
417
+ class="p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800"
418
+ role="alert"
419
+ >
420
+ <p class="text-red-700 dark:text-red-300 text-sm font-medium mb-3">
421
+ {{ responseError.message || responseError.error || $t("user_flow_api_error") }}
422
+ </p>
423
+ <button
424
+ type="button"
425
+ class="w-full flex justify-center py-2 px-4 border border-red-300 dark:border-red-700 rounded-lg
426
+ text-red-700 dark:text-red-300 bg-white dark:bg-red-900/30
427
+ hover:bg-red-50 dark:hover:bg-red-900/50 transition-all duration-200
428
+ focus:outline-none focus:ring-2 focus:ring-red-500 dark:focus:ring-red-600 font-medium"
429
+ @click="handlePageRefresh"
430
+ >
431
+ {{ $t("user_flow_refresh_page") }}
432
+ </button>
433
+ </div>
385
434
 
386
435
  <!-- Password recovery link -->
387
436
  <div
388
- v-if="responseReq.includes('password') && 0"
437
+ v-if="responseReq.includes('password') && response?.data?.user"
389
438
  class="text-right my-2"
390
439
  >
391
440
  <button
@@ -31,7 +31,7 @@ interface ConfirmWithInputModalData {
31
31
 
32
32
  const _onConfirm = useDebounceFn(async () => {
33
33
  // If expectedValue is set, validate the input
34
- if (expectedValue.value && inputValue.value !== expectedValue.value) {
34
+ if (expectedValue.value && inputValue.value.toLocaleLowerCase() !== expectedValue.value.toLocaleLowerCase()) {
35
35
  inputError.value = errorMessage.value || 'Incorrect value entered'
36
36
  return
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "2.3.81",
3
+ "version": "2.3.83",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/fy-to/FWJS#readme",