feat: implement identity api
This commit is contained in:
parent
0b5e066aab
commit
5f97e8c7d8
|
@ -1,9 +1,15 @@
|
||||||
import type {AuthProvider} from "@refinedev/core"
|
import type {AuthProvider} from "@refinedev/core"
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AuthActionResponse,
|
||||||
|
CheckResponse,
|
||||||
|
IdentityResponse,
|
||||||
|
OnErrorResponse
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import type {AuthActionResponse, CheckResponse, OnErrorResponse} 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 Cookies from 'universal-cookie';
|
||||||
|
import type {AccountInfoResponse} from "@lumeweb/portal-sdk";
|
||||||
|
|
||||||
export type AuthFormRequest = {
|
export type AuthFormRequest = {
|
||||||
email: string;
|
email: string;
|
||||||
|
@ -19,6 +25,13 @@ export type RegisterFormRequest = {
|
||||||
lastName: string;
|
lastName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Identity = {
|
||||||
|
id: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class PortalAuthProvider implements RequiredAuthProvider {
|
export class PortalAuthProvider implements RequiredAuthProvider {
|
||||||
private sdk: Sdk;
|
private sdk: Sdk;
|
||||||
|
|
||||||
|
@ -118,8 +131,21 @@ export class PortalAuthProvider implements RequiredAuthProvider {
|
||||||
return {success: true};
|
return {success: true};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getIdentity(params?: any): Promise<AuthActionResponse> {
|
async getIdentity(params?: Identity): Promise<IdentityResponse> {
|
||||||
return {id: "1", fullName: "John Doe", avatar: "https://via.placeholder.com/150"};
|
const ret = await this.sdk.account().info();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return {identity: null};
|
||||||
|
}
|
||||||
|
|
||||||
|
const acct = ret as AccountInfoResponse;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: acct.id,
|
||||||
|
firstName: acct.first_name,
|
||||||
|
lastName: acct.last_name,
|
||||||
|
email: acct.email,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static create(apiUrl: string): AuthProvider {
|
public static create(apiUrl: string): AuthProvider {
|
||||||
|
|
Loading…
Reference in New Issue