private void Initialise()
 {
     _iDCredential = new DCredential();
     _iFCredential = new FCredential(_iDCredential);
     _iDRole       = new DRole();
     _iFRole       = new FRole(_iDRole);
 }
Example #2
0
 public ViewPageController()
 {
     //_iFEmployee = new FEmployee();
     _iFRole     = new FRole();
     _iFUser     = new FUser();
     _iFUserRole = new FUserRole();
 }
Example #3
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            bool authorized = false;

            if (AllowAnonymous || (Cookies.IsLoggedIn && AllowedRoles.Length == 0))
            {
                authorized = true;
            }
            else if (Cookies.IsLoggedIn)
            {
                _iDCredential = new DCredential();
                _iDRole       = new DRole();
                _iFCredential = new FCredential(_iDCredential);
                _iFRole       = new FRole(_iDRole);

                authorized = _iFRole.HasRole(Cookies.CredentialId, AllowedRoles);
            }

            if (!authorized && !string.IsNullOrEmpty(RedirectController) && !string.IsNullOrEmpty(RedirectMethod))
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = RedirectController, action = RedirectMethod }));
            }
            else if (!authorized)
            {
                filterContext.Result = new HttpUnauthorizedResult();
            }
        }
Example #4
0
 public MvcAuthorizationFilterAttribute(bool allowAnonymous, string redirectController, string redirectMethod, string[] allowedRoles)
 {
     AllowAnonymous     = allowAnonymous;
     AllowedRoles       = allowedRoles;
     RedirectController = redirectController;
     RedirectMethod     = redirectMethod;
     _iDCredential      = new DCredential();
     _iDRole            = new DRole();
     _iFCredential      = new FCredential(_iDCredential);
     _iFRole            = new FRole(_iDRole);
 }
Example #5
0
 public MvcAuthorizationFilterAttribute(bool allowAnonymous)
 {
     AllowAnonymous     = allowAnonymous;
     RedirectController = string.Empty;
     RedirectMethod     = string.Empty;
     AllowedRoles       = new string[0];
     _iDCredential      = new DCredential();
     _iDRole            = new DRole();
     _iFCredential      = new FCredential(_iDCredential);
     _iDRole            = new DRole();
     _iFRole            = new FRole(_iDRole);
 }
Example #6
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            string currentUserlogged = WindowsUser.Username;

            try
            {
                _iDUser = new DUser();
                _iDRole = new DRole();
                _iFUser = new FUser(_iDUser);
                _iFRole = new FRole(_iDRole);
                return(_iFUser.IsMethodAccessible(currentUserlogged, AllowedRoles.ToList()));
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #7
0
 public RoleController(IFRole iFRole)
 {
     _iFRole = iFRole;
 }