rentease/internal/auth/service.go
Ruidy ac10e65097
Refactor service (#14)
* add comments to main file

* create health check handler

health check

* use naming convention for booking handler

* use naming convention for hamndlers

naming convention

* clean up
2024-08-07 09:12:50 +02:00

35 lines
733 B
Go

package auth
import "errors"
type Service struct {
secret string
admin string
adminSecret string
apiKey string
}
type ProviderIndex struct {
ProvidersMap map[string]string
Providers []string
}
func NewService(secret, admin, adminSecret, apiKey string) (*Service, error) {
if secret == "" || admin == "" || adminSecret == "" || apiKey == "" {
return nil, errors.New("error building Auth service. Verify your env variables")
}
return &Service{
secret,
admin,
adminSecret,
apiKey,
}, nil
}
func (as *Service) Authenticate(email, password string) bool {
return email == as.admin && password == as.adminSecret
}
func (as *Service) ValidateApiKey(key string) bool {
return key == as.apiKey
}