Fix role and organization logo
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/crewjam/saml"
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
)
|
||||
|
||||
func ExtractAttributeValue(assertion *saml.Assertion, attributeName string) (string, error) {
|
||||
@@ -76,12 +77,12 @@ func ExtractEmailDomain(email string) (string, error) {
|
||||
return domain, nil
|
||||
}
|
||||
|
||||
func MapSAMLRoleToSystemRole(samlRole string) string {
|
||||
func MapSAMLRoleToSystemRole(samlRole string) coredata.Role {
|
||||
if samlRole != "" && isValidRole(samlRole) {
|
||||
return samlRole
|
||||
return coredata.Role(samlRole)
|
||||
}
|
||||
|
||||
return "MEMBER"
|
||||
return coredata.RoleMember
|
||||
}
|
||||
|
||||
func isValidRole(role string) bool {
|
||||
|
||||
@@ -407,7 +407,7 @@ func (s *SAMLService) InitiateSAMLLogin(
|
||||
type SAMLUserInfo struct {
|
||||
Email string
|
||||
FullName string
|
||||
Role string
|
||||
Role coredata.Role
|
||||
SAMLSubject string
|
||||
OrganizationID gid.GID
|
||||
SAMLConfigID gid.GID
|
||||
|
||||
@@ -1055,15 +1055,9 @@ func (s Service) GetOrganizationLogoFile(
|
||||
organizationID gid.GID,
|
||||
session *coredata.Session,
|
||||
) (*coredata.File, error) {
|
||||
// Check authentication requirements before allowing access to logo
|
||||
err := s.CheckSingleOrganizationAccess(ctx, user, organizationID, session)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("access denied: %w", err)
|
||||
}
|
||||
|
||||
var logoFile *coredata.File
|
||||
|
||||
err = s.pg.WithConn(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
scope := coredata.NewScope(organizationID.TenantID())
|
||||
|
||||
Reference in New Issue
Block a user