Add authentication system with session-based auth
All checks were successful
Build and Push Backend / build (push) Successful in 20s

- Implement register, login, logout, and me endpoints
- Use bcryptjs for password hashing
- HTTPOnly secure cookies for sessions (Lucia Auth pattern)
- Users and sessions tables with proper relations
- 7-day session duration with auto-expiry

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hector Ros
2026-01-20 01:56:25 +01:00
parent 5672127593
commit 1dc0ab515d
12 changed files with 1226 additions and 1 deletions

37
test-auth.ts Normal file
View File

@@ -0,0 +1,37 @@
/**
* Test authentication directly
*/
import { db } from './src/db/client'
import { users } from './src/db/schema'
import { randomUUID } from 'crypto'
import bcrypt from 'bcryptjs'
async function testAuth() {
try {
console.log('Testing auth...')
// Hash password
const passwordHash = await bcrypt.hash('test123', 10)
console.log('Password hash:', passwordHash)
// Insert user
const userId = randomUUID()
console.log('Inserting user with ID:', userId)
await db.insert(users).values({
id: userId,
email: 'test@test.com',
username: 'testuser',
passwordHash,
})
console.log('User inserted successfully!')
} catch (error) {
console.error('Error:', error)
}
process.exit(0)
}
testAuth()