Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions backend/internal/user/repo/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ func NewUserRepo(
}

func (r *UserRepo) InitAdmin(ctx context.Context, username, password string) error {
_, err := r.AdminByName(ctx, username)
admin, err := r.AdminByName(ctx, username)
if db.IsNotFound(err) {
_, err = r.CreateAdmin(ctx, &db.Admin{
if _, err := r.CreateAdmin(ctx, &db.Admin{
Username: username,
Password: password,
Status: consts.AdminStatusActive,
}, 1)
}, 1); err != nil {
return err
}
}
if err != nil {
return err
}
return nil
return r.db.Admin.UpdateOneID(admin.ID).SetPassword(password).Exec(ctx)
}

func (r *UserRepo) CreateAdmin(ctx context.Context, admin *db.Admin, roleID int64) (*db.Admin, error) {
Expand Down
Loading