feat: clear local authentication token when switching from local auth mode
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { ClerkProvider } from "@clerk/nextjs";
|
||||
import type { ReactNode } from "react";
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
|
||||
import { isLikelyValidClerkPublishableKey } from "@/auth/clerkKey";
|
||||
import { getLocalAuthToken, isLocalAuthMode } from "@/auth/localAuth";
|
||||
import {
|
||||
clearLocalAuthToken,
|
||||
getLocalAuthToken,
|
||||
isLocalAuthMode,
|
||||
} from "@/auth/localAuth";
|
||||
import { LocalAuthLogin } from "@/components/organisms/LocalAuthLogin";
|
||||
|
||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
if (isLocalAuthMode()) {
|
||||
const localMode = isLocalAuthMode();
|
||||
|
||||
useEffect(() => {
|
||||
if (!localMode) {
|
||||
clearLocalAuthToken();
|
||||
}
|
||||
}, [localMode]);
|
||||
|
||||
if (localMode) {
|
||||
if (!getLocalAuthToken()) {
|
||||
return <LocalAuthLogin />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user