All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
37 lines
951 B
Go
37 lines
951 B
Go
package models
|
|
|
|
// User represents the full DB user field, for inserts and compares.
|
|
// No reason to return the hashed pw on the route though.
|
|
type User struct {
|
|
UserID int64
|
|
Username string
|
|
DisplayName string
|
|
Password []byte
|
|
}
|
|
|
|
// UserNoPassword contains the non password user fields.
|
|
// This is preferred outside of the model / store.
|
|
type UserNoPassword struct {
|
|
UserID int64 `json:"user_id"`
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display_name"`
|
|
}
|
|
|
|
// User returns a single plan from the store by plan_id.
|
|
func (m *Model) User(id int) (*UserNoPassword, error) {
|
|
user, err := m.SelectUserByID(id)
|
|
if user == nil {
|
|
return nil, wrapNotFound(err)
|
|
}
|
|
return user.NoPassword(), wrapNotFound(err)
|
|
}
|
|
|
|
// NoPassword strips the user of password.
|
|
func (u *User) NoPassword() *UserNoPassword {
|
|
return &UserNoPassword{
|
|
UserID: u.UserID,
|
|
Username: u.Username,
|
|
DisplayName: u.DisplayName,
|
|
}
|
|
}
|