2020-01-15 04:22:34 +01:00
|
|
|
package model
|
2020-01-14 22:11:27 +01:00
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
type User struct {
|
2020-01-28 14:22:17 +01:00
|
|
|
ID string `json:"id" orm:"column(id)"`
|
|
|
|
UserName string `json:"userName"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
IsAdmin bool `json:"isAdmin"`
|
|
|
|
LastLoginAt *time.Time `json:"lastLoginAt"`
|
|
|
|
LastAccessAt *time.Time `json:"lastAccessAt"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
2021-05-02 00:03:45 +02:00
|
|
|
|
|
|
|
// This is only available on the backend, and it is never sent over the wire
|
|
|
|
Password string `json:"-"`
|
|
|
|
// This is used to set or change a password when calling Put. If it is empty, the password is not changed.
|
|
|
|
// It is received from the UI with the name "password"
|
|
|
|
NewPassword string `json:"password,omitempty"`
|
2021-05-03 21:03:34 +02:00
|
|
|
// If changing the password, this is also required
|
|
|
|
CurrentPassword string `json:"currentPassword,omitempty"`
|
2020-01-14 22:11:27 +01:00
|
|
|
}
|
2020-01-20 04:36:15 +01:00
|
|
|
|
2020-01-28 14:22:17 +01:00
|
|
|
type Users []User
|
|
|
|
|
2020-01-20 04:36:15 +01:00
|
|
|
type UserRepository interface {
|
|
|
|
CountAll(...QueryOptions) (int64, error)
|
|
|
|
Get(id string) (*User, error)
|
|
|
|
Put(*User) error
|
2020-07-11 20:38:17 +02:00
|
|
|
FindFirstAdmin() (*User, error)
|
2020-03-01 21:45:41 +01:00
|
|
|
// FindByUsername must be case-insensitive
|
2020-01-20 15:54:29 +01:00
|
|
|
FindByUsername(username string) (*User, error)
|
|
|
|
UpdateLastLoginAt(id string) error
|
2020-01-20 19:35:59 +01:00
|
|
|
UpdateLastAccessAt(id string) error
|
2020-01-20 04:36:15 +01:00
|
|
|
}
|