wet-aquaW
Refine3y ago
20 replies
wet-aqua

Authentication not working

After using my custom authProvider, when I login and its successful, the login state doesn't persist and I still get redirected back to the login page and not the authenticated pages.
What could be happening

export const authProvider: AuthBindings = {
  login: async ({ reference, passcode, providerName }) => {
    try {
      const { data } = await axiosInstance.get(
        `${API_BASE_URL}/authentication/otp/verify`,
        {
          params: { passcode, reference },
        }
      );
      localStorage.setItem("authToken", data.token);

      return {
        success: true,
        redirectTo: "/",
      };
    } catch (error: any) {
      console.error(error);
      return {
        success: false,
        error: {
          message: "message" in error ? error.message : "Login failed",
          name: "Invalid OTP",
        },
      };
    }
  },
Was this page helpful?