@fy-/fws-vue 2.3.82 → 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.
- package/components/fws/UserFlow.vue +66 -17
- package/package.json +1 -1
|
@@ -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
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
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') &&
|
|
437
|
+
v-if="responseReq.includes('password') && response?.data?.user"
|
|
389
438
|
class="text-right my-2"
|
|
390
439
|
>
|
|
391
440
|
<button
|