cake-order-tracker/internal/auth/credentials.go
2025-03-28 21:53:04 +01:00

19 lines
393 B
Go

package auth
import (
"errors"
"github.com/Bronku/iroon/internal/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")
}