fix: apply password change redirect fix to regular modal too (#263)
The redirect loop fix only covered MandatoryPasswordChangeModal. The regular PasswordChangeModal (profile settings) had the same issue — onSuccess updated React state but didn't handle the new JWT cookie, causing the same redirect loop. Also increase redirect delay from 500ms to 2000ms in both modals so the success toast is visible before the page reloads.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -30,14 +30,12 @@ export const PasswordChangeModal: React.FC<PasswordChangeModalProps> = ({ 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) {
|
||||
|
||||
Reference in New Issue
Block a user