-
Notifications
You must be signed in to change notification settings - Fork 2
/
user.go
28 lines (23 loc) · 880 Bytes
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package domain
import (
"crypto/sha1"
p "github.com/wuriyanto48/go-pbkdf2"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// User model
type User struct {
ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
FullName string `json:"fullName" bson:"fullName"`
Email string `json:"email" bson:"email"`
Password string `json:"password" bson:"password"`
Salt string `json:"salt" bson:"salt"`
CreatedAt string `json:"createdAt" bson:"createdAt"`
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
Photo string `json:"photo" bson:"photo"`
}
// IsValidPassword function
func (u *User) IsValidPassword(password string) bool {
pass := p.NewPassword(sha1.New, 8, 32, 1000)
isValid := pass.VerifyPassword(password, u.Password, u.Salt)
return isValid
}