create structure for rules checking
This commit is contained in:
@@ -26,3 +26,44 @@ func grabOrgFromUser(user viewmodel.User) (viewmodel.Organization, error) {
|
||||
|
||||
return user.Organizations[0], nil
|
||||
}
|
||||
|
||||
func CanCreateOrganization(user viewmodel.User, organization viewmodel.Organization ) bool {
|
||||
//TODO : implement checking
|
||||
|
||||
userRole, err := grabProfileFromUser(user)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
/*Admin Provider Manage all Organizations */
|
||||
if userRole.Key == providerAdmin{
|
||||
return true
|
||||
}
|
||||
|
||||
/* Admin BCBSI Manage all Organizations */
|
||||
if userRole.Key == bcbsiAdmin{
|
||||
return true
|
||||
}
|
||||
|
||||
/* Admin Technical Support Manage all Organizations */
|
||||
if userRole.Key == brighterDevAdmin{
|
||||
return true
|
||||
}
|
||||
|
||||
/* Admin Plan
|
||||
Manage the authenticated Authorized User's Plan (Organization) and children of this Plan*/
|
||||
if userRole.Key == planAdmin {
|
||||
return true
|
||||
}
|
||||
|
||||
/* Super Admin Technical Support Manage all Organizations*/
|
||||
if userRole.Key == superAdmin {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func CanUpdateOrganization(user viewmodel.User, organization viewmodel.Organization) bool {
|
||||
return CanCreateOrganization(user,organization)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user