refactor: use handleResponse on login
This commit is contained in:
parent
729414c45a
commit
b3f0044723
|
@ -86,20 +86,15 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => {
|
||||||
password: params.password,
|
password: params.password,
|
||||||
});
|
});
|
||||||
|
|
||||||
let redirectTo: string | undefined;
|
return handleResponse({
|
||||||
|
ret, redirectToSuccess: "/dashboard", redirectToError: "/login", successCb: () => {
|
||||||
if (ret) {
|
|
||||||
redirectTo = params.redirectTo;
|
|
||||||
if (!redirectTo) {
|
|
||||||
redirectTo = ret ? "/dashboard" : "/login";
|
|
||||||
}
|
|
||||||
sdk.setAuthToken(sdk.account().jwtToken);
|
sdk.setAuthToken(sdk.account().jwtToken);
|
||||||
}
|
}, successNotification: {
|
||||||
|
message: "Login Successful",
|
||||||
|
description: "You have successfully logged in."
|
||||||
|
|
||||||
return {
|
}
|
||||||
success: ret,
|
});
|
||||||
redirectTo,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async logout(params: any): Promise<AuthActionResponse> {
|
async logout(params: any): Promise<AuthActionResponse> {
|
||||||
|
|
Loading…
Reference in New Issue