Exemplo n.º 1
0
        public AbilityConfigurator(IAbilityConfiguration config, IPrincipal principal)
        {
            Trace.Write(string.Format("Checking abilities of user '{0}'", principal.Identity.IsAuthenticated ? principal.Identity.Name : "unauthenticated user"));
            if (principal.IsInRole("admin"))
            {
                config.AllowAnything().OnEverything();
            }

            if (principal.IsInRole("manager"))
            {
                config.AllowAnything().On("Customer");
            }

            if (principal.IsInRole("callcenter"))
            {
                config.Allow("View", "Edit").On("Customer");
            }

            if (principal.IsInRole("viewer"))
            {
                config.Allow("View").On("Customer");
            }

            config.ConfigureSubjectAliases("Customer", "Customers");
        }
Exemplo n.º 2
0
        public AbilityConfigurator(IAbilityConfiguration config, IPrincipal principal)
        {
            config.Allow("SignIn", "SignOut").On("Account");
            config.AllowTo("View", "Home");

            if (principal.IsInRole("guest"))
            {
                config.AllowTo("list", "customer");
            }

            if (principal.IsInRole("admin"))
            {
                config.AllowTo("Manage", "All");
            }

            if (principal.IsInRole("manager"))
            {
                config.AllowTo("Manage", "Customer");
            }

            if (principal.IsInRole("callcenter"))
            {
                config.Allow("View", "Edit").On("Customer");
            }

            if (principal.IsInRole("viewer"))
            {
                config.Allow("View").On("Customer");
            }

            config.IgnoreSubjectPostfixes("ViewModel");
            config.ConfigureSubjectAliases("Customer", "Customers");
            config.ConfigureCommandConvention("{action}{subject}Command");
        }