package models import ( "golang.org/x/crypto/bcrypt" "gorm.io/gorm" ) type User struct { gorm.Model DisplayName string Email string `gorm:"unique"` Salt string HashedPassword []byte } func (u *User) MatchesPassword(password string) bool { combined := append([]byte(u.Salt), []byte(password)...) return bcrypt.CompareHashAndPassword(u.HashedPassword, []byte(combined)) == nil }