fix: resolve password change redirect loop and file watcher crash
#263: The mandatory password change modal updated React state before the browser stored the new JWT cookie, causing a race condition where the auth context checked the session with the old (invalidated) token. Replace the state update with a full page redirect to /admin/dashboard after a brief delay, ensuring the new cookie is applied cleanly. #269: The file watcher service imported isVideoMimeType from fileSecurityUtils where it doesn't exist. The function is exported from videoProcessor. Fix the import path. Closes #269
This commit is contained in:
@@ -5,7 +5,7 @@ const { db } = require('../database/db');
|
|||||||
const { formatBoolean } = require('../utils/dbCompat');
|
const { formatBoolean } = require('../utils/dbCompat');
|
||||||
const { generateThumbnail, generateVideoPlaceholder } = require('./imageProcessor');
|
const { generateThumbnail, generateVideoPlaceholder } = require('./imageProcessor');
|
||||||
const logger = require('../utils/logger');
|
const logger = require('../utils/logger');
|
||||||
const { isVideoMimeType } = require('../utils/fileSecurityUtils');
|
const { isVideoMimeType } = require('./videoProcessor');
|
||||||
const mime = require('mime-types');
|
const mime = require('mime-types');
|
||||||
|
|
||||||
const getStoragePath = () => process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
const getStoragePath = () => process.env.STORAGE_PATH || path.join(__dirname, '../../../storage');
|
||||||
|
|||||||
@@ -27,14 +27,12 @@ export const MandatoryPasswordChangeModal: React.FC = () => {
|
|||||||
mutationFn: adminService.changePassword,
|
mutationFn: adminService.changePassword,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t('mandatoryPasswordChange.success'));
|
toast.success(t('mandatoryPasswordChange.success'));
|
||||||
updatePasswordChanged();
|
// Force a full page reload so the browser picks up the new JWT cookie
|
||||||
// Reset form
|
// set by the backend. A React state update alone causes a race condition
|
||||||
setFormData({
|
// where the auth context checks the session before the cookie is stored.
|
||||||
currentPassword: '',
|
setTimeout(() => {
|
||||||
newPassword: '',
|
window.location.href = '/admin/dashboard';
|
||||||
confirmPassword: ''
|
}, 500);
|
||||||
});
|
|
||||||
setErrors({});
|
|
||||||
},
|
},
|
||||||
onError: (error: any) => {
|
onError: (error: any) => {
|
||||||
if (error.response?.data?.error) {
|
if (error.response?.data?.error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user