mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-28 06:37:57 +08:00
This pull request introduces the new Flowpilot system along with several new features and various improvements. The key enhancements include configurable authorization, registration, and profile flows, as well as the ability to enable and disable user identifiers (e.g., email addresses and usernames) and login methods. --------- Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io> Co-authored-by: Lennart Fleischmann <lennart.fleischmann@hanko.io> Co-authored-by: lfleischmann <67686424+lfleischmann@users.noreply.github.com> Co-authored-by: merlindru <hello@merlindru.com>
36 lines
870 B
Go
36 lines
870 B
Go
package models
|
|
|
|
import (
|
|
"github.com/gobuffalo/pop/v6"
|
|
"github.com/gobuffalo/validate/v3"
|
|
"github.com/gobuffalo/validate/v3/validators"
|
|
"github.com/gofrs/uuid"
|
|
"time"
|
|
)
|
|
|
|
type Username struct {
|
|
ID uuid.UUID `db:"id"`
|
|
UserId uuid.UUID `db:"user_id"`
|
|
Username string `db:"username"`
|
|
CreatedAt time.Time `db:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at"`
|
|
}
|
|
|
|
func NewUsername(userId uuid.UUID, username string) *Username {
|
|
id, _ := uuid.NewV4()
|
|
return &Username{
|
|
ID: id,
|
|
UserId: userId,
|
|
Username: username,
|
|
CreatedAt: time.Now(),
|
|
UpdatedAt: time.Now(),
|
|
}
|
|
}
|
|
|
|
func (username *Username) Validate(tx *pop.Connection) (*validate.Errors, error) {
|
|
return validate.Validate(
|
|
&validators.StringIsPresent{Name: "Username", Field: username.Username},
|
|
&validators.UUIDIsPresent{Name: "UserId", Field: username.UserId},
|
|
), nil
|
|
}
|