mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Fix admin user creation
This commit is contained in:
@@ -80,14 +80,20 @@ func (db *DB) GetUserByID(id int) (*models.User, error) {
|
||||
|
||||
func (db *DB) GetUserByEmail(email string) (*models.User, error) {
|
||||
user := &models.User{}
|
||||
var lastOpenedFilePath sql.NullString
|
||||
err := db.QueryRow(`
|
||||
SELECT id, email, display_name, password_hash, role, created_at, last_workspace_id, last_opened_file_path
|
||||
FROM users WHERE email = ?`, email).
|
||||
Scan(&user.ID, &user.Email, &user.DisplayName, &user.PasswordHash, &user.Role, &user.CreatedAt,
|
||||
&user.LastWorkspaceID, &user.LastOpenedFilePath)
|
||||
&user.LastWorkspaceID, &lastOpenedFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if lastOpenedFilePath.Valid {
|
||||
user.LastOpenedFilePath = lastOpenedFilePath.String
|
||||
} else {
|
||||
user.LastOpenedFilePath = ""
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func (s *UserService) SetupAdminUser() (*models.User, error) {
|
||||
|
||||
// Check if admin user exists
|
||||
adminUser, err := s.DB.GetUserByEmail(adminEmail)
|
||||
if err == nil {
|
||||
if adminUser != nil {
|
||||
return adminUser, nil // Admin user already exists
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user