19 lines
384 B
Go
19 lines
384 B
Go
package auth
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/Bronku/iroon/crypto"
|
|
)
|
|
|
|
func (a *Authenticator) verifyCredentials(login, password string) error {
|
|
user, ok := a.s.GetUser(login)
|
|
if !ok {
|
|
return errors.New("user with this login doesn't exist")
|
|
}
|
|
hash := crypto.PasswordHash(password, user.Salt)
|
|
if hash == user.Password {
|
|
return nil
|
|
}
|
|
return errors.New("wrong credentials")
|
|
}
|