Add PDF reports, file uploads, admin auth, and comprehensive tests
Features: - PDF service for generating task reports with ReportLab-style formatting - Storage service for file uploads (local and S3-compatible) - Admin authentication middleware with JWT support - Admin user model and repository Infrastructure: - Updated Docker configuration for admin panel builds - Email service enhancements for task notifications - Updated router with admin and file upload routes - Environment configuration updates Tests: - Unit tests for handlers (auth, residence, task) - Unit tests for models (user, residence, task) - Unit tests for repositories (user, residence, task) - Unit tests for services (residence, task) - Integration test setup - Test utilities for mocking database and services Database: - Admin user seed data - Updated test data seeds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -124,6 +124,9 @@ func Migrate() error {
|
||||
&models.ConfirmationCode{},
|
||||
&models.PasswordResetCode{},
|
||||
|
||||
// Admin users (separate from app users)
|
||||
&models.AdminUser{},
|
||||
|
||||
// Main entity tables (order matters for foreign keys!)
|
||||
&models.Residence{},
|
||||
&models.ResidenceShareCode{},
|
||||
@@ -412,5 +415,26 @@ func migrateGoAdmin() error {
|
||||
}
|
||||
|
||||
log.Info().Msg("GoAdmin migrations completed")
|
||||
|
||||
// Seed default Next.js admin user (email: admin@mycrib.com, password: admin123)
|
||||
// bcrypt hash for "admin123": $2a$10$t5hGjdXQLxr9Z0193qx.Tef6hd1vYI3JvrfX/piKx2qS9UvQ41I9O
|
||||
var adminCount int64
|
||||
db.Raw(`SELECT COUNT(*) FROM admin_users WHERE email = 'admin@mycrib.com'`).Scan(&adminCount)
|
||||
if adminCount == 0 {
|
||||
log.Info().Msg("Seeding default admin user for Next.js admin panel...")
|
||||
db.Exec(`
|
||||
INSERT INTO admin_users (email, password, first_name, last_name, role, is_active, created_at, updated_at)
|
||||
VALUES ('admin@mycrib.com', '$2a$10$t5hGjdXQLxr9Z0193qx.Tef6hd1vYI3JvrfX/piKx2qS9UvQ41I9O', 'Admin', 'User', 'super_admin', true, NOW(), NOW())
|
||||
`)
|
||||
log.Info().Msg("Default admin user created: admin@mycrib.com / admin123")
|
||||
} else {
|
||||
// Update existing admin password if needed
|
||||
db.Exec(`
|
||||
UPDATE admin_users SET password = '$2a$10$t5hGjdXQLxr9Z0193qx.Tef6hd1vYI3JvrfX/piKx2qS9UvQ41I9O'
|
||||
WHERE email = 'admin@mycrib.com'
|
||||
`)
|
||||
log.Info().Msg("Updated admin@mycrib.com password to admin123")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user