diff --git a/frontend/src/components/admin/MandatoryPasswordChangeModal.tsx b/frontend/src/components/admin/MandatoryPasswordChangeModal.tsx index 1f2bc88f..fad6753d 100644 --- a/frontend/src/components/admin/MandatoryPasswordChangeModal.tsx +++ b/frontend/src/components/admin/MandatoryPasswordChangeModal.tsx @@ -32,7 +32,7 @@ export const MandatoryPasswordChangeModal: React.FC = () => { // where the auth context checks the session before the cookie is stored. setTimeout(() => { window.location.href = '/admin/dashboard'; - }, 500); + }, 2000); }, onError: (error: any) => { if (error.response?.data?.error) { diff --git a/frontend/src/components/admin/PasswordChangeModal.tsx b/frontend/src/components/admin/PasswordChangeModal.tsx index b7ac3472..88ce4de8 100644 --- a/frontend/src/components/admin/PasswordChangeModal.tsx +++ b/frontend/src/components/admin/PasswordChangeModal.tsx @@ -30,14 +30,12 @@ export const PasswordChangeModal: React.FC = ({ isOpen mutationFn: adminService.changePassword, onSuccess: () => { toast.success(t('passwordChange.success')); - onClose(); - // Reset form - setFormData({ - currentPassword: '', - newPassword: '', - confirmPassword: '' - }); - setErrors({}); + // Full page reload so the browser picks up the new JWT cookie. + // Same fix as MandatoryPasswordChangeModal — without this, the old + // token gets rejected and causes a redirect loop. + setTimeout(() => { + window.location.href = '/admin/dashboard'; + }, 2000); }, onError: (error: any) => { if (error.response?.data?.error) {