Enable user authentication and authorization throughout the application
Refactors authentication logic into AuthContext and removes useAuth hook. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 556aa286-edd2-4cea-8583-f4fc3cfd119b
This commit is contained in:
@@ -14,6 +14,8 @@ interface AuthContextType {
|
||||
|
||||
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
||||
|
||||
export { AuthContext };
|
||||
|
||||
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
@@ -1,10 +1 @@
|
||||
import { useContext } from "react";
|
||||
import { AuthContext } from "@/context/AuthContext";
|
||||
|
||||
export function useAuth() {
|
||||
const context = useContext(AuthContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("useAuth must be used within an AuthProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
export { useAuth } from "@/context/AuthContext";
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
|
||||
export default function LandingPage() {
|
||||
const [, setLocation] = useLocation();
|
||||
const { user } = useAuth() || {};
|
||||
const { user } = useAuth();
|
||||
const { isListening, startListening, stopListening, isSupported } = useVoice();
|
||||
const { theme } = useTheme();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user