refactor: pass ret as a HttpError
This commit is contained in:
parent
6ce3b02dc6
commit
9332598627
|
@ -1,4 +1,4 @@
|
||||||
import type {AuthProvider, UpdatePasswordFormTypes} from "@refinedev/core"
|
import type {AuthProvider, HttpError, UpdatePasswordFormTypes} from "@refinedev/core"
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AuthActionResponse,
|
AuthActionResponse,
|
||||||
|
@ -8,10 +8,9 @@ import type {
|
||||||
SuccessNotificationResponse
|
SuccessNotificationResponse
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
} from "@refinedev/core/dist/interfaces/bindings/auth"
|
} from "@refinedev/core/dist/interfaces/bindings/auth"
|
||||||
import {Sdk} from "@lumeweb/portal-sdk";
|
import {Sdk, AccountError} from "@lumeweb/portal-sdk";
|
||||||
import type {AccountInfoResponse} from "@lumeweb/portal-sdk";
|
import type {AccountInfoResponse} from "@lumeweb/portal-sdk";
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
export type AuthFormRequest = {
|
export type AuthFormRequest = {
|
||||||
email: string;
|
email: string;
|
||||||
|
@ -60,10 +59,10 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
|
|
||||||
const handleResponse = (result: ResponseResult): AuthActionResponse => {
|
const handleResponse = (result: ResponseResult): AuthActionResponse => {
|
||||||
if (result.ret) {
|
if (result.ret) {
|
||||||
if (result.ret instanceof Error) {
|
if (result.ret instanceof AccountError) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: result.ret,
|
error: result.ret satisfies HttpError,
|
||||||
redirectTo: result.redirectToError
|
redirectTo: result.redirectToError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue