feat: implement updatePassword
This commit is contained in:
parent
8ca46c6f18
commit
b65bd12c8a
|
@ -31,6 +31,11 @@ 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;
|
||||||
|
@ -95,8 +100,26 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
return {success: true};
|
return {success: true};
|
||||||
},
|
},
|
||||||
|
|
||||||
async updatePassword(params: any): Promise<AuthActionResponse> {
|
async updatePassword(params: UpdatePasswordFormRequest): Promise<AuthActionResponse> {
|
||||||
return { success: true };
|
maybeSetupAuth();
|
||||||
|
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> {
|
||||||
|
|
Loading…
Reference in New Issue