dealroom/internal/rbac/rbac.go

27 lines
716 B
Go

package rbac
import "dealroom/internal/model"
// IsSeller returns true if role is owner or admin
func IsSeller(role string) bool {
return role == "owner" || role == "admin"
}
// IsBuyer returns true if role is viewer or member
func IsBuyer(role string) bool {
return role == "viewer" || role == "member"
}
// EffectiveIsBuyer returns true if ViewAsBuyer is set OR real role is buyer
func EffectiveIsBuyer(profile *model.Profile) bool {
return profile.ViewAsBuyer || IsBuyer(profile.Role)
}
// BuyerGroups returns the buyer groups for the demo buyer
func BuyerGroups(profile *model.Profile) []string {
if IsBuyer(profile.Role) {
return []string{"Meridian Capital", "Summit Health Equity"}
}
return nil
}