-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #522 from teamhanko/feat-add-user-admin-endpoints
feat: add query params to search users
- Loading branch information
Showing
7 changed files
with
272 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package admin | ||
|
||
import ( | ||
"github.com/gofrs/uuid" | ||
"github.com/teamhanko/hanko/backend/persistence/models" | ||
"time" | ||
) | ||
|
||
type Email struct { | ||
ID uuid.UUID `json:"id"` | ||
Address string `json:"address"` | ||
IsVerified bool `json:"is_verified"` | ||
IsPrimary bool `json:"is_primary"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
} | ||
|
||
// FromEmailModel Converts the DB model to a DTO object | ||
func FromEmailModel(email *models.Email) *Email { | ||
return &Email{ | ||
ID: email.ID, | ||
Address: email.Address, | ||
IsVerified: email.Verified, | ||
IsPrimary: email.IsPrimary(), | ||
CreatedAt: email.CreatedAt, | ||
UpdatedAt: email.UpdatedAt, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package admin | ||
|
||
import ( | ||
"github.com/gofrs/uuid" | ||
"github.com/teamhanko/hanko/backend/dto" | ||
"github.com/teamhanko/hanko/backend/persistence/models" | ||
"time" | ||
) | ||
|
||
type User struct { | ||
ID uuid.UUID `json:"id"` | ||
WebauthnCredentials []dto.WebauthnCredentialResponse `json:"webauthn_credentials,omitempty"` | ||
Emails []Email `json:"emails,omitempty"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
} | ||
|
||
// FromUserModel Converts the DB model to a DTO object | ||
func FromUserModel(model models.User) User { | ||
credentials := make([]dto.WebauthnCredentialResponse, len(model.WebauthnCredentials)) | ||
for i := range model.WebauthnCredentials { | ||
credentials[i] = *dto.FromWebauthnCredentialModel(&model.WebauthnCredentials[i]) | ||
} | ||
emails := make([]Email, len(model.Emails)) | ||
for i := range model.Emails { | ||
emails[i] = *FromEmailModel(&model.Emails[i]) | ||
} | ||
return User{ | ||
ID: model.ID, | ||
WebauthnCredentials: credentials, | ||
Emails: emails, | ||
CreatedAt: model.CreatedAt, | ||
UpdatedAt: model.UpdatedAt, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.