Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions context/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ export function AuthProvider({ children }) {
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);

// Check for existing session on app start
useEffect(() => {
const checkSession = async () => {
try {
const result = await authAPI.validateSession();
if (result.valid) {
setUser(result.user);
} else {
setUser(null);
}
} catch (error) {
} finally {
setLoading(false);
}
};

checkSession();
}, []);

const checkSession = async () => {
try {
const result = await authAPI.validateSession();
if (result.valid) {
setUser(result.user);
} else {
setUser(null);
}
} catch (error) {
console.error('Session check failed:', error);
} finally {
setLoading(false);
}
};

const login = async (email, password) => {
const result = await authAPI.login(email, password);
if (result.success) {
Expand Down