Beispiel #1
0
// Authenticate check if email and password are correct and if have
// authorization for use the client
func (u User) Authenticate(email, password, secretKey string) bool {
	salt := u.EncryptPassword[0:2]

	encrypted := crypt.Crypt(password, salt)

	return (email == u.Email) && (encrypted == u.EncryptPassword) && u.HasClientAccess(secretKey)
}
Beispiel #2
0
// SetPassword sets the user password after encrypt it
func (u *User) SetPassword(password string) {
	u.EncryptPassword = crypt.Crypt(password, crypt.RandStringBytes(2))
}