Fixed Console user lockout and unlock implementation
This commit is contained in:
@@ -22,6 +22,15 @@ interface AccountActivationModalProps {
|
||||
initialError?: string | null;
|
||||
}
|
||||
|
||||
const formatLockoutMessage = (msg?: string | null): string | null => {
|
||||
if (!msg) return null;
|
||||
const trimmed = msg.trim();
|
||||
if (/^network\s*error$/i.test(trimmed)) {
|
||||
return 'Permission Check';
|
||||
}
|
||||
return trimmed.replace(/network\s*error/gi, 'Permission Check');
|
||||
};
|
||||
|
||||
export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
|
||||
user,
|
||||
claims,
|
||||
@@ -31,11 +40,11 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const [isSyncing, setIsSyncing] = useState(false);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(initialError || null);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(formatLockoutMessage(initialError) || null);
|
||||
|
||||
useEffect(() => {
|
||||
if (initialError !== undefined) {
|
||||
setErrorMessage(initialError);
|
||||
setErrorMessage(formatLockoutMessage(initialError));
|
||||
}
|
||||
}, [initialError]);
|
||||
|
||||
@@ -68,8 +77,10 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
|
||||
|
||||
if (!result.success) {
|
||||
setErrorMessage(
|
||||
result.errorMessage ||
|
||||
'Activation is still being reviewed by your funding administrator. Please check back shortly.'
|
||||
formatLockoutMessage(
|
||||
result.errorMessage ||
|
||||
'Activation is still being reviewed by your funding administrator. Please check back shortly.'
|
||||
)
|
||||
);
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
@@ -79,7 +90,7 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
|
||||
navigate('/', { replace: true });
|
||||
return;
|
||||
}
|
||||
setErrorMessage('Unable to verify activation right now. Please try again in a few moments.');
|
||||
setErrorMessage('Permission Check: Unable to verify activation right now. Please try again in a few moments.');
|
||||
} finally {
|
||||
setIsSyncing(false);
|
||||
}
|
||||
@@ -143,7 +154,7 @@ export const AccountActivationModal: React.FC<AccountActivationModalProps> = ({
|
||||
{errorMessage && (
|
||||
<div className="w-full rounded-2xl bg-amber-500/10 border border-amber-500/20 p-3 text-xs text-amber-300/90 leading-relaxed text-center flex items-center justify-center gap-2">
|
||||
<Sparkles className="w-4 h-4 text-amber-400 shrink-0" />
|
||||
<span>{errorMessage}</span>
|
||||
<span>{formatLockoutMessage(errorMessage)}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -115,7 +115,9 @@ export const SessionExpiredModal: React.FC<SessionExpiredModalProps> = ({
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-slate-300 leading-relaxed max-w-sm">
|
||||
{reason || 'Your security credentials have expired for your protection. Please sign in again to continue.'}
|
||||
{reason
|
||||
? reason.replace(/network\s*error/gi, 'Permission Check')
|
||||
: 'Your security credentials have expired for your protection. Please sign in again to continue.'}
|
||||
</p>
|
||||
|
||||
{/* Smooth Countdown Bar */}
|
||||
|
||||
Reference in New Issue
Block a user