Skip to content

Commit

Permalink
fix(admin-api): return webauthn transports in users endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
lfleischmann committed Sep 30, 2024
1 parent 579cef3 commit b3a4355
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions backend/persistence/user_persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ func (p *userPersister) List(page int, perPage int, userId uuid.UUID, email stri

query := p.db.
Q().
EagerPreload("Emails", "Emails.PrimaryEmail", "WebauthnCredentials", "Username").
EagerPreload(
"Emails",
"Emails.PrimaryEmail",
"WebauthnCredentials",
"WebauthnCredentials.Transports",
"Username").
LeftJoin("emails", "emails.user_id = users.id").
LeftJoin("usernames", "usernames.user_id = users.id")
query = p.addQueryParamsToSqlQuery(query, userId, email, username)
Expand All @@ -156,10 +161,20 @@ func (p *userPersister) List(page int, perPage int, userId uuid.UUID, email stri

func (p *userPersister) All() ([]models.User, error) {
users := []models.User{}
err := p.db.EagerPreload("Emails", "Emails.PrimaryEmail", "Emails.Identities", "WebauthnCredentials", "Username").All(&users)

err := p.db.EagerPreload(
"Emails",
"Emails.PrimaryEmail",
"Emails.Identities",
"WebauthnCredentials",
"WebauthnCredentials.Transports",
"Username",
).All(&users)

if err != nil && errors.Is(err, sql.ErrNoRows) {
return users, nil
}

if err != nil {
return nil, fmt.Errorf("failed to fetch users: %w", err)
}
Expand Down

0 comments on commit b3a4355

Please sign in to comment.