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:
ghaddaditw
2025-05-30 17:11:54 +00:00
parent 51d13203fd
commit 99977d5f56
3 changed files with 4 additions and 11 deletions
+2
View File
@@ -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
View File
@@ -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";
+1 -1
View File
@@ -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();