Compare commits
No commits in common. "b65bd12c8abbf53b675ff8ab3f60b95cec70017e" and "2dccaca132ddf6d49e6393a5db7b1e1b9bf10f95" have entirely different histories.
b65bd12c8a
...
2dccaca132
|
@ -31,11 +31,6 @@ export type Identity = {
|
||||||
email: string;
|
email: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdatePasswordFormRequest = {
|
|
||||||
currentPassword: string;
|
|
||||||
newPassword: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
const maybeSetupAuth = (): void => {
|
const maybeSetupAuth = (): void => {
|
||||||
const jwt = sdk.account().jwtToken;
|
const jwt = sdk.account().jwtToken;
|
||||||
|
@ -69,7 +64,7 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
|
|
||||||
async logout(params: any): Promise<AuthActionResponse> {
|
async logout(params: any): Promise<AuthActionResponse> {
|
||||||
let ret = await sdk.account().logout();
|
let ret = await sdk.account().logout();
|
||||||
return {success: ret, redirectTo: "/login"};
|
return { success: ret, redirectTo: "/login" };
|
||||||
},
|
},
|
||||||
|
|
||||||
async check(params?: any): Promise<CheckResponse> {
|
async check(params?: any): Promise<CheckResponse> {
|
||||||
|
@ -79,11 +74,11 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
maybeSetupAuth();
|
maybeSetupAuth();
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
return {logout: true};
|
return { logout: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
async register(params: RegisterFormRequest): Promise<AuthActionResponse> {
|
async register(params: RegisterFormRequest): Promise<AuthActionResponse> {
|
||||||
|
@ -93,37 +88,19 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
first_name: params.firstName,
|
first_name: params.firstName,
|
||||||
last_name: params.lastName,
|
last_name: params.lastName,
|
||||||
});
|
});
|
||||||
return {success: ret, redirectTo: ret ? "/dashboard" : undefined};
|
return { success: ret, redirectTo: ret ? "/dashboard" : undefined };
|
||||||
},
|
},
|
||||||
|
|
||||||
async forgotPassword(params: any): Promise<AuthActionResponse> {
|
async forgotPassword(params: any): Promise<AuthActionResponse> {
|
||||||
return {success: true};
|
return { success: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
async updatePassword(params: UpdatePasswordFormRequest): Promise<AuthActionResponse> {
|
async updatePassword(params: any): Promise<AuthActionResponse> {
|
||||||
maybeSetupAuth();
|
return { success: true };
|
||||||
const ret = await sdk.account().updatePassword(params.currentPassword, params.newPassword);
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
if (ret instanceof Error) {
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
error: ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
success: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async getPermissions(params?: Record<string, any>): Promise<AuthActionResponse> {
|
async getPermissions(params?: Record<string, any>): Promise<AuthActionResponse> {
|
||||||
return {success: true};
|
return { success: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
async getIdentity(params?: Identity): Promise<IdentityResponse> {
|
async getIdentity(params?: Identity): Promise<IdentityResponse> {
|
||||||
|
@ -131,7 +108,7 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
const ret = await sdk.account().info();
|
const ret = await sdk.account().info();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
return {identity: null};
|
return { identity: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
const acct = ret as AccountInfoResponse;
|
const acct = ret as AccountInfoResponse;
|
||||||
|
|
|
@ -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-20240319140708",
|
"@lumeweb/portal-sdk": "0.0.0-20240319120038",
|
||||||
"@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",
|
||||||
|
|
Loading…
Reference in New Issue