protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } if (Roles == null) { throw new ArgumentNullException("Roles required in parametrs"); } if (httpContext.User.Identity.IsAuthenticated == false) { return(false); } try { var current_tc_name = TCHelper.GetCurrentTCName(); var roles = Roles.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var role in roles) { var tcRole = RolesHelper.RoleForTc(role, current_tc_name); if (httpContext.User.IsInRole(tcRole) || httpContext.User.IsInRole(role)) { return(true); } } return(false); } catch (Exception) { // TODO Нужны логи сюда! return(false); } }
/// <summary> /// Подстраивается под тренинг центр, при указании role "admin" в учебном центре usltu проверит на роль "admin_ulstu" /// </summary> /// <param name="role"></param> /// <returns></returns> public static bool IsUserHasPermissionForTc(string role) { var tc = TCHelper.GetCurrentTCName(); return(IsUserHasPermissionForTc(role, tc)); }