30 lines
782 B
Go
30 lines
782 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 user
|
|
func BuyerGroups(profile *model.Profile) []string {
|
|
if profile.BuyerGroup != "" {
|
|
return []string{profile.BuyerGroup}
|
|
}
|
|
if IsBuyer(profile.Role) {
|
|
return []string{"Meridian Capital", "Summit Health Equity"}
|
|
}
|
|
return nil
|
|
}
|