diff --git a/backend/app.js b/backend/app.js index c6cca11..291d596 100644 --- a/backend/app.js +++ b/backend/app.js @@ -26,6 +26,8 @@ if (config.trustProxy !== false) { console.log(`[Trust Proxy] Disabled (value: false)`); } +console.log(`[Trust Proxy] Express setting confirmed:`, app.get('trust proxy')); + // Session store const sessionStore = new SequelizeStore({ db: sequelize, diff --git a/backend/migrations/20260420000004-make-password-optional.js b/backend/migrations/20260420000004-make-password-optional.js index 4713912..99d835a 100644 --- a/backend/migrations/20260420000004-make-password-optional.js +++ b/backend/migrations/20260420000004-make-password-optional.js @@ -48,6 +48,26 @@ module.exports = { ); `); + const [columns] = await queryInterface.sequelize.query( + 'PRAGMA table_info(users);' + ); + const hasPasswordDigest = columns.some( + (col) => col.name === 'password_digest' + ); + const hasPassword = columns.some((col) => col.name === 'password'); + + const passwordColumn = hasPasswordDigest + ? 'password_digest' + : hasPassword + ? 'password' + : null; + + if (!passwordColumn) { + throw new Error( + 'Neither password nor password_digest column found in users table' + ); + } + await queryInterface.sequelize.query(` INSERT INTO users_new ( id, uid, name, surname, email, password_digest, appearance, language, @@ -64,7 +84,7 @@ module.exports = { ) SELECT id, uid, name, surname, email, - COALESCE(password_digest, password) as password_digest, + ${passwordColumn} as password_digest, appearance, language, timezone, first_day_of_week, avatar_image, telegram_bot_token, telegram_chat_id, task_summary_enabled, task_summary_frequency,