Compare commits
2 Commits
d1e059fd71
...
7293cb0b5a
Author | SHA1 | Date |
---|---|---|
|
7293cb0b5a | |
|
ba374a851c |
|
@ -8,7 +8,6 @@ import type {
|
|||
// @ts-ignore
|
||||
} from "@refinedev/core/dist/interfaces/bindings/auth"
|
||||
import {Sdk} from "@lumeweb/portal-sdk";
|
||||
import Cookies from 'universal-cookie';
|
||||
import type {AccountInfoResponse} from "@lumeweb/portal-sdk";
|
||||
|
||||
export type AuthFormRequest = {
|
||||
|
@ -91,15 +90,16 @@ export class PortalAuthProvider implements RequiredAuthProvider {
|
|||
}
|
||||
|
||||
async check(params?: any): Promise<CheckResponse> {
|
||||
this.maybeSetupAuth();
|
||||
|
||||
const ret = await this._sdk.account().ping();
|
||||
|
||||
if(ret){
|
||||
this.maybeSetupAuth();
|
||||
}
|
||||
|
||||
return {authenticated: ret, redirectTo: ret ? undefined : "/login"};
|
||||
}
|
||||
|
||||
async onError(error: any): Promise<OnErrorResponse> {
|
||||
const cookies = new Cookies();
|
||||
return {logout: true};
|
||||
}
|
||||
|
||||
|
@ -144,10 +144,9 @@ export class PortalAuthProvider implements RequiredAuthProvider {
|
|||
}
|
||||
|
||||
maybeSetupAuth(): void {
|
||||
const cookies = new Cookies();
|
||||
const jwtCookie = cookies.get('auth_token');
|
||||
if (jwtCookie) {
|
||||
this._sdk.setAuthToken(jwtCookie);
|
||||
const jwt = this._sdk.account().jwtToken
|
||||
if (jwt) {
|
||||
this._sdk.setAuthToken(jwt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"@conform-to/react": "^1.0.2",
|
||||
"@conform-to/zod": "^1.0.2",
|
||||
"@fontsource-variable/manrope": "^5.0.19",
|
||||
"@lumeweb/portal-sdk": "0.0.0-20240318183202",
|
||||
"@lumeweb/portal-sdk": "0.0.0-20240318212259",
|
||||
"@radix-ui/react-avatar": "^1.0.4",
|
||||
"@radix-ui/react-checkbox": "^1.0.4",
|
||||
"@radix-ui/react-dialog": "^1.0.5",
|
||||
|
@ -45,7 +45,6 @@
|
|||
"react-dom": "^18.2.0",
|
||||
"tailwind-merge": "^2.2.1",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"universal-cookie": "^7.1.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue