I was wondering how I would go about determining if a user is within a certain role?
All I can think of is
NopContext.Current.User.CustomerRoles
Is there something like
NopContext.Current.User.CustomerRole("Admin");?
Thanks
protected virtual bool ValidateVendorSecurity()
{
CustomerRole role = CustomerManager.GetCustomerRoleByID(5); // role id 5 = vendor
Customer customer = CustomerManager.GetCustomerByID(NopContext.Current.User.CustomerID);
if (NopContext.Current == null ||
NopContext.Current.User == null ||
NopContext.Current.User.IsGuest)
{
return false;
}
else
{
return CustomerManager.GetCustomerRolesByCustomerID(customer.CustomerID).Contains(role);
}
}