fix: resolve backend startup errors in development
Mirror to GitHub / mirror (push) Successful in 25s
Test and Lint / backend-test (push) Successful in 1m23s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m13s
Version and Release / version-bump (push) Successful in 45s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 25s
Test and Lint / backend-test (push) Successful in 1m23s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m13s
Version and Release / version-bump (push) Successful in 45s
Version and Release / trigger-drone (push) Successful in 3s
- Added STORAGE_PATH environment variable and volume mount for storage directory - Fixed authSecurity functions to check if login_attempts table exists before using it - Prevents errors when running with only core migrations (new deployments) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,12 @@ const ATTEMPT_WINDOW = 15 * 60 * 1000; // 15 minutes window for counting attempt
|
|||||||
*/
|
*/
|
||||||
async function trackFailedAttempt(identifier, ipAddress, userAgent) {
|
async function trackFailedAttempt(identifier, ipAddress, userAgent) {
|
||||||
try {
|
try {
|
||||||
|
// Check if table exists first
|
||||||
|
const tableExists = await db.schema.hasTable('login_attempts');
|
||||||
|
if (!tableExists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await db('login_attempts').insert({
|
await db('login_attempts').insert({
|
||||||
identifier,
|
identifier,
|
||||||
ip_address: ipAddress,
|
ip_address: ipAddress,
|
||||||
@@ -48,6 +54,12 @@ async function trackFailedAttempt(identifier, ipAddress, userAgent) {
|
|||||||
*/
|
*/
|
||||||
async function trackSuccessfulLogin(identifier, ipAddress, userAgent) {
|
async function trackSuccessfulLogin(identifier, ipAddress, userAgent) {
|
||||||
try {
|
try {
|
||||||
|
// Check if table exists first
|
||||||
|
const tableExists = await db.schema.hasTable('login_attempts');
|
||||||
|
if (!tableExists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await db('login_attempts').insert({
|
await db('login_attempts').insert({
|
||||||
identifier,
|
identifier,
|
||||||
ip_address: ipAddress,
|
ip_address: ipAddress,
|
||||||
@@ -75,6 +87,12 @@ async function trackSuccessfulLogin(identifier, ipAddress, userAgent) {
|
|||||||
*/
|
*/
|
||||||
async function checkAccountLockout(identifier) {
|
async function checkAccountLockout(identifier) {
|
||||||
try {
|
try {
|
||||||
|
// Check if table exists first
|
||||||
|
const tableExists = await db.schema.hasTable('login_attempts');
|
||||||
|
if (!tableExists) {
|
||||||
|
return { isLocked: false };
|
||||||
|
}
|
||||||
|
|
||||||
const recentWindow = new Date(Date.now() - ATTEMPT_WINDOW);
|
const recentWindow = new Date(Date.now() - ATTEMPT_WINDOW);
|
||||||
|
|
||||||
// Get recent failed attempts
|
// Get recent failed attempts
|
||||||
@@ -114,6 +132,12 @@ async function checkAccountLockout(identifier) {
|
|||||||
*/
|
*/
|
||||||
async function checkSuspiciousActivity(identifier, ipAddress) {
|
async function checkSuspiciousActivity(identifier, ipAddress) {
|
||||||
try {
|
try {
|
||||||
|
// Check if table exists first
|
||||||
|
const tableExists = await db.schema.hasTable('login_attempts');
|
||||||
|
if (!tableExists) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for rapid attempts from different IPs
|
// Check for rapid attempts from different IPs
|
||||||
const recentWindow = new Date(Date.now() - 5 * 60 * 1000); // 5 minutes
|
const recentWindow = new Date(Date.now() - 5 * 60 * 1000); // 5 minutes
|
||||||
|
|
||||||
@@ -153,6 +177,13 @@ function getGenericAuthError() {
|
|||||||
*/
|
*/
|
||||||
async function cleanupOldAttempts() {
|
async function cleanupOldAttempts() {
|
||||||
try {
|
try {
|
||||||
|
// Check if table exists first
|
||||||
|
const tableExists = await db.schema.hasTable('login_attempts');
|
||||||
|
if (!tableExists) {
|
||||||
|
// Table doesn't exist, skip cleanup
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const cutoffDate = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); // 7 days
|
const cutoffDate = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); // 7 days
|
||||||
|
|
||||||
const deleted = await db('login_attempts')
|
const deleted = await db('login_attempts')
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ services:
|
|||||||
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:3000}
|
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:3000}
|
||||||
- ADMIN_URL=${ADMIN_URL:-http://localhost:3001}
|
- ADMIN_URL=${ADMIN_URL:-http://localhost:3001}
|
||||||
- TZ=${TZ:-UTC}
|
- TZ=${TZ:-UTC}
|
||||||
|
- STORAGE_PATH=/app/storage
|
||||||
volumes:
|
volumes:
|
||||||
- ./events:/app/events
|
- ./events:/app/events
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
|
|||||||
Reference in New Issue
Block a user