Refactored UI endpoint usage
This commit is contained in:
@@ -131,7 +131,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
// Subscribe to global HTTP 401 session expiration events
|
||||
useEffect(() => {
|
||||
const unsubscribe = onSessionExpired((reason) => {
|
||||
// Subordination: If account activation lockout is active, session expiration is completely avoided and bypassed
|
||||
// If account activation is pending, suppress session expiration modal
|
||||
if (isPendingActivation || isActivationPending()) {
|
||||
return;
|
||||
}
|
||||
@@ -148,8 +148,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
};
|
||||
}, [accessToken, isPendingActivation]);
|
||||
|
||||
// Priority Subordination: When activation process is active, dismiss all other modals,
|
||||
// cancel session expiration and avoid its processes so that there is no overlapping.
|
||||
// When account activation is pending, ensure secondary dialogs are closed
|
||||
useEffect(() => {
|
||||
if (isPendingActivation) {
|
||||
setIsSessionExpired(false);
|
||||
@@ -159,7 +158,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
}
|
||||
}, [isPendingActivation]);
|
||||
|
||||
// When session expiration modal is displayed, dismiss all other subordinates
|
||||
// When session expiration modal is displayed, dismiss background modals
|
||||
useEffect(() => {
|
||||
if (isSessionExpired) {
|
||||
dismissSubordinateModals();
|
||||
@@ -221,10 +220,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
// Clean up code and state from URL
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
|
||||
// Execute user sync endpoint upon login.
|
||||
// If HTTP 401 -> routes to landing page
|
||||
// If non-401 failure -> displays non-dismissable activation modal
|
||||
// If success -> saved in browser to prevent endpoint hotspot
|
||||
// Synchronize authenticated user profile with backend directory
|
||||
try {
|
||||
const syncResult = await syncUserAccount(userSub, token, profile, true);
|
||||
if (syncResult.isUnauthorized) {
|
||||
|
||||
Reference in New Issue
Block a user