gogmagog/models/user.go
Deepak 1d45635530
Some checks failed
gitea-deepak/gogmagog/pipeline/head There was a failure building this commit
adds no password return by default, model cares about password but nothing downstream does
2021-01-11 20:37:35 -06:00

34 lines
800 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
}
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)
}
func (u *User) NoPassword() *UserNoPassword {
return &UserNoPassword{
UserID: u.UserID,
Username: u.Username,
DisplayName: u.DisplayName,
}
}