* Oauth: change error type to a struct that unwraps into a social error * Oauth: Handle empty role in error and fix unwrap * Oauth: provide more informatio in error * Oauth: return InvalidBasicRoleError * Oauth: Fix tests * Login: Remove casing * Oath: Change to warning logs
31 lines
676 B
Go
31 lines
676 B
Go
package social
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
var (
|
|
ErrIDTokenNotFound = errors.New("id_token not found")
|
|
ErrEmailNotFound = errors.New("error getting user info: no email found in access token")
|
|
)
|
|
|
|
type InvalidBasicRoleError struct {
|
|
idP string
|
|
assignedRole string
|
|
}
|
|
|
|
func (e *InvalidBasicRoleError) Error() string {
|
|
withFallback := func(v, fallback string) string {
|
|
if v == "" {
|
|
return fallback
|
|
}
|
|
return v
|
|
}
|
|
return fmt.Sprintf("Integration requires a valid org role assigned in %s. Assigned role: %s", withFallback(e.idP, "idP"), withFallback(e.assignedRole, "\" \""))
|
|
}
|
|
|
|
func (e *InvalidBasicRoleError) Unwrap() error {
|
|
return &Error{e.Error()}
|
|
}
|