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