diff --git a/app/data/auth-provider.ts b/app/data/auth-provider.ts index 25acbc6..d6d38eb 100644 --- a/app/data/auth-provider.ts +++ b/app/data/auth-provider.ts @@ -54,6 +54,10 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => { successCb?: () => void; } + interface CheckResponseResult extends ResponseResult { + authenticated?: boolean; + } + const handleResponse = (result: ResponseResult): AuthActionResponse => { if (result.ret) { if (result.ret instanceof Error) { @@ -79,6 +83,17 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => { } } + const handleCheckResponse = (result: CheckResponseResult): CheckResponse => { + const response = handleResponse(result); + const success = response.success; + delete response.success; + + return { + ...response, + authenticated: success + } + } + return { async login(params: AuthFormRequest): Promise { const ret = await sdk.account().login({ @@ -105,7 +120,7 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => { async check(params?: any): Promise { const ret = await sdk.account().ping(); - return handleResponse({ret, redirectToError: "/login", successCb: maybeSetupAuth}); + return handleCheckResponse({ret, redirectToError: "/login", successCb: maybeSetupAuth}); }, async onError(error: any): Promise {