feat(accounts): add admin accounts and user preferences
Remove public registration, support administrator-managed accounts, and persist personal preferences. Refs #2 #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -66,7 +66,12 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func ensureAdmin(repo *models.Repository, cfg *config.Config) error {
|
||||
type adminRepository interface {
|
||||
GetUserByEmail(string) (*models.User, error)
|
||||
CreateUser(string, string, models.Role) (*models.User, error)
|
||||
}
|
||||
|
||||
func ensureAdmin(repo adminRepository, cfg *config.Config) error {
|
||||
if cfg.AdminEmail == "" {
|
||||
return nil
|
||||
}
|
||||
@ -77,6 +82,9 @@ func ensureAdmin(repo *models.Repository, cfg *config.Config) error {
|
||||
if existing != nil {
|
||||
return nil
|
||||
}
|
||||
if cfg.AdminPassword == "" {
|
||||
return fmt.Errorf("ADMIN_PASSWORD is required to create the bootstrap admin")
|
||||
}
|
||||
hash, err := auth.HashPassword(cfg.AdminPassword)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user