refactor: use handleResponse on login

This commit is contained in:
Derrick Hammer 2024-03-20 13:43:51 -04:00
parent 729414c45a
commit b3f0044723
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 12 deletions

View File

@ -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: () => {
sdk.setAuthToken(sdk.account().jwtToken);
}, successNotification: {
message: "Login Successful",
description: "You have successfully logged in."
if (ret) {
redirectTo = params.redirectTo;
if (!redirectTo) {
redirectTo = ret ? "/dashboard" : "/login";
} }
sdk.setAuthToken(sdk.account().jwtToken); });
}
return {
success: ret,
redirectTo,
};
}, },
async logout(params: any): Promise<AuthActionResponse> { async logout(params: any): Promise<AuthActionResponse> {