51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package authorization
|
|
|
|
import (
|
|
|
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
|
)
|
|
|
|
func CanCreateAddress(user viewmodel.User, address viewmodel.OrganizationAddress) 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 CanUpdateAddress(user viewmodel.User, address viewmodel.OrganizationAddress) bool {
|
|
return CanCreateAddress(user, address)
|
|
}
|
|
|
|
func CanDeleteAddress(user viewmodel.User, address viewmodel.OrganizationAddress) bool {
|
|
return CanCreateAddress(user, address)
|
|
} |