// 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) }
// SetPassword sets the user password after encrypt it func (u *User) SetPassword(password string) { u.EncryptPassword = crypt.Crypt(password, crypt.RandStringBytes(2)) }