mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 12:46:53 +00:00
* 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
35 lines
733 B
Go
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
|
|
}
|