Verification emails
This commit is contained in:
@ -7,7 +7,6 @@ func HashPassword(password string, cost int) (string, error) {
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func CheckPasswordHash(password, hash string) bool {
|
||||
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||
return err == nil
|
||||
func CheckPasswordHash(password, hash string) error {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ func TestHashValid(t *testing.T) {
|
||||
password := "qwertyu9"
|
||||
hpass, err := hash.HashPassword(password, 10)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, hash.CheckPasswordHash(password, hpass))
|
||||
assert.NoError(t, hash.CheckPasswordHash(password, hpass))
|
||||
}
|
||||
|
||||
func TestHashInvalid(t *testing.T) {
|
||||
password := "qwertyu9"
|
||||
invhash := "qwertyu9"
|
||||
assert.False(t, hash.CheckPasswordHash(password, invhash))
|
||||
assert.Error(t, hash.CheckPasswordHash(password, invhash))
|
||||
}
|
||||
|
Reference in New Issue
Block a user