calendrier/models/user.go

21 lines
474 B
Go
Raw Normal View History

2024-02-24 16:01:08 +01:00
package models
import (
"github.com/uptrace/bun"
"golang.org/x/crypto/bcrypt"
)
type User struct {
bun.BaseModel `bun:"table:c_user"`
Id int `json:"id" bun:"id,pk,autoincrement"`
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password"`
}
func (u *User) HashPassword() error {
tmp, err := bcrypt.GenerateFromPassword([]byte(u.Password), bcrypt.DefaultCost)
u.Password = string(tmp)
return err
}