Removed setUserLockout from PartnerUI
This commit is contained in:
@@ -17,7 +17,6 @@ import { AccountActivationModal } from '../components/auth/AccountActivationModa
|
||||
import { NonPartnerAccessDeniedModal } from '../components/auth/NonPartnerAccessDeniedModal';
|
||||
import { SessionExpiredModal } from '../components/auth/SessionExpiredModal';
|
||||
import { encodeHashIdSync } from '../services/toolsService';
|
||||
import { verifyTenantLockout, clearTenantLockoutCache } from '../services/tenantLockoutService';
|
||||
import {
|
||||
onSessionExpired,
|
||||
triggerSessionExpired,
|
||||
@@ -510,35 +509,6 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 3: Verify tenant lockout using the HashId-encoded tenant ID
|
||||
const effectiveTenantId =
|
||||
parsedTenantId ??
|
||||
syncResult.data?.tenantId ??
|
||||
syncResult.data?.organisationId ??
|
||||
tenantClaimValues.tenantId;
|
||||
|
||||
const tenantLockoutResult = await verifyTenantLockout(effectiveTenantId, tenantClaim);
|
||||
|
||||
if (!tenantLockoutResult.isActive) {
|
||||
setIsPendingActivation(true);
|
||||
setIsSynced(false);
|
||||
setActivationError(tenantLockoutResult.errorMessage || 'Tenant is inactive or not found');
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tenantLockoutResult.tenant?.name) {
|
||||
profile.tenant = tenantLockoutResult.tenant.name;
|
||||
setTenantName(tenantLockoutResult.tenant.name);
|
||||
}
|
||||
if (tenantLockoutResult.tenant?.id !== undefined && !profile.tenant_id) {
|
||||
const numericTid = Number(tenantLockoutResult.tenant.id);
|
||||
if (!isNaN(numericTid) && numericTid > 0) {
|
||||
profile.tenant_id = numericTid;
|
||||
setTenantId(numericTid);
|
||||
}
|
||||
}
|
||||
|
||||
setUser({ ...profile });
|
||||
localStorage.setItem(LOCAL_STORAGE_USER_KEY, JSON.stringify(profile));
|
||||
|
||||
@@ -669,39 +639,6 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 3: Verify tenant lockout using HashId-encoded tenant ID
|
||||
const effectiveTenantId =
|
||||
storedTenantId ??
|
||||
syncResult.data?.tenantId ??
|
||||
syncResult.data?.organisationId ??
|
||||
tenantClaimValues.tenantId;
|
||||
|
||||
const tenantLockoutResult = await verifyTenantLockout(
|
||||
effectiveTenantId,
|
||||
storedTenantClaim,
|
||||
hadPendingActivation
|
||||
);
|
||||
|
||||
if (!tenantLockoutResult.isActive) {
|
||||
setIsPendingActivation(true);
|
||||
setIsSynced(false);
|
||||
setActivationError(tenantLockoutResult.errorMessage || 'Tenant is inactive or not found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (tenantLockoutResult.tenant?.name) {
|
||||
if (resolvedUser) {
|
||||
resolvedUser.tenant = tenantLockoutResult.tenant.name;
|
||||
}
|
||||
setTenantName(tenantLockoutResult.tenant.name);
|
||||
}
|
||||
if (tenantLockoutResult.tenant?.id !== undefined && resolvedUser && !resolvedUser.tenant_id) {
|
||||
const numericTid = Number(tenantLockoutResult.tenant.id);
|
||||
if (!isNaN(numericTid) && numericTid > 0) {
|
||||
resolvedUser.tenant_id = numericTid;
|
||||
setTenantId(numericTid);
|
||||
}
|
||||
}
|
||||
if (resolvedUser) {
|
||||
setUser({ ...resolvedUser });
|
||||
localStorage.setItem(LOCAL_STORAGE_USER_KEY, JSON.stringify(resolvedUser));
|
||||
@@ -746,8 +683,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
const syncUserSession = async (force = true): Promise<UserSyncResult> => {
|
||||
try {
|
||||
await loadRuntimeConfig();
|
||||
clearTenantLockoutCache();
|
||||
if (sub) {
|
||||
if (sub) {
|
||||
clearCachedUserRbac(sub);
|
||||
}
|
||||
|
||||
@@ -793,41 +729,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
localStorage.setItem(LOCAL_STORAGE_CLAIMS_KEY, JSON.stringify(resolved.claims));
|
||||
} catch {}
|
||||
|
||||
const tenantClaimValues = extractTenantClaimValues(claims, accessToken);
|
||||
const effectiveTenantId =
|
||||
currentTenantId ??
|
||||
result.data?.tenantId ??
|
||||
result.data?.organisationId ??
|
||||
tenantClaimValues.tenantId;
|
||||
const effectiveTenantClaim = currentTenantClaim || tenantClaimValues.tenant || undefined;
|
||||
|
||||
// Step 3: Verify tenant lockout using HashId-encoded tenant ID
|
||||
const tenantLockoutResult = await verifyTenantLockout(
|
||||
effectiveTenantId,
|
||||
effectiveTenantClaim,
|
||||
true
|
||||
);
|
||||
if (!tenantLockoutResult.isActive) {
|
||||
const msg = tenantLockoutResult.errorMessage || 'Tenant is not Active. Lockout active.';
|
||||
setIsPendingActivation(true);
|
||||
setIsSynced(false);
|
||||
setActivationError(msg);
|
||||
return {
|
||||
success: false,
|
||||
isActivationPending: true,
|
||||
errorMessage: msg,
|
||||
};
|
||||
}
|
||||
|
||||
if (tenantLockoutResult.tenant?.name) {
|
||||
setTenantName(tenantLockoutResult.tenant.name);
|
||||
}
|
||||
if (tenantLockoutResult.tenant?.id !== undefined && !tenantId) {
|
||||
const numericTid = Number(tenantLockoutResult.tenant.id);
|
||||
if (!isNaN(numericTid) && numericTid > 0) {
|
||||
setTenantId(numericTid);
|
||||
}
|
||||
}
|
||||
// Partner user verified successfully
|
||||
|
||||
setActivationPending(false);
|
||||
setIsPendingActivation(false);
|
||||
@@ -873,8 +775,7 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
||||
localStorage.removeItem(LOCAL_STORAGE_SUB_KEY);
|
||||
localStorage.removeItem(LOCAL_STORAGE_CLAIMS_KEY);
|
||||
clearUserSyncInBrowser();
|
||||
clearTenantLockoutCache();
|
||||
setUser(null);
|
||||
setUser(null);
|
||||
setSub('');
|
||||
setClaims({});
|
||||
setTenantId(null);
|
||||
|
||||
Reference in New Issue
Block a user