Add password change flow and auth error handling
- Add ChangePasswordPage component for forced password changes - Add RequirePasswordChange wrapper in App.tsx to redirect users - Add custom error classes (UnauthorizedError, ForbiddenError) in api.ts - Add 401/403 error handling in ProjectPage and PackagePage - Add refreshUser function to AuthContext - Add must_change_password field to User type - Add access denied UI for forbidden resources
This commit is contained in:
@@ -8,6 +8,7 @@ interface AuthContextType {
|
||||
error: string | null;
|
||||
login: (username: string, password: string) => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
refreshUser: () => Promise<void>;
|
||||
clearError: () => void;
|
||||
}
|
||||
|
||||
@@ -71,8 +72,17 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
||||
setError(null);
|
||||
}, []);
|
||||
|
||||
const refreshUser = useCallback(async () => {
|
||||
try {
|
||||
const currentUser = await getCurrentUser();
|
||||
setUser(currentUser);
|
||||
} catch {
|
||||
setUser(null);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ user, loading, error, login, logout, clearError }}>
|
||||
<AuthContext.Provider value={{ user, loading, error, login, logout, refreshUser, clearError }}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user