WIP: Something is going on
This commit is contained in:
@ -5,13 +5,13 @@ import (
|
||||
)
|
||||
|
||||
type EmailConf struct {
|
||||
From string
|
||||
From string
|
||||
Password string
|
||||
SmtpHost string
|
||||
SmtpPort string
|
||||
}
|
||||
|
||||
func (e *EmailConf) SendEmail (to string, message string )error {
|
||||
func (e *EmailConf) SendEmail(to string, message string) error {
|
||||
messageByte := []byte(message)
|
||||
auth := smtp.PlainAuth("", e.From, e.Password, e.SmtpHost)
|
||||
|
||||
@ -19,4 +19,4 @@ func (e *EmailConf) SendEmail (to string, message string )error {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ func HashPassword(password string, cost int) (string, error) {
|
||||
}
|
||||
|
||||
func CheckPasswordHash(password, hash string) bool {
|
||||
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||
return err == nil
|
||||
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,14 @@ import (
|
||||
)
|
||||
|
||||
func TestHashValid(t *testing.T) {
|
||||
password := "qwertyu9"
|
||||
hpass, err := hash.HashPassword(password, 10)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, hash.CheckPasswordHash(password, hpass))
|
||||
password := "qwertyu9"
|
||||
hpass, err := hash.HashPassword(password, 10)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, hash.CheckPasswordHash(password, hpass))
|
||||
}
|
||||
|
||||
func TestHashInvalid(t *testing.T) {
|
||||
password := "qwertyu9"
|
||||
invhash := "qwertyu9"
|
||||
assert.False(t, hash.CheckPasswordHash(password, invhash))
|
||||
password := "qwertyu9"
|
||||
invhash := "qwertyu9"
|
||||
assert.False(t, hash.CheckPasswordHash(password, invhash))
|
||||
}
|
||||
|
Reference in New Issue
Block a user