示例#1
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var userControlledBehavior = player.Behaviors.FindFirst <UserControlledBehavior>();

            userControlledBehavior.SecurityRoles |= role;

            var ob = new OutputBuilder();

            ob.AppendLine($"{player.Name} has been granted the {role.ToString()} role.");
            ob.AppendLine($"{player.Name} is now: {userControlledBehavior.SecurityRoles}.");
            actionInput.Controller.Write(ob);

            ob.Clear();
            ob.AppendLine($"You have been granted the {role.ToString()} role.");
            userControlledBehavior.Controller.Write(ob);

            player.FindBehavior <PlayerBehavior>()?.SavePlayer();
        }
示例#2
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender = actionInput.Controller;
            var         userControlledBehavior = player.Behaviors.FindFirst <UserControlledBehavior>();

            userControlledBehavior.SecurityRoles &= ~role;
            sender.Write($"{player.Name} has been revoked the {role.ToString()} role.");
            sender.Write($"{player.Name} is now: {userControlledBehavior.SecurityRoles}.");
            // TODO: Should this notify the target user too?
            player.FindBehavior <PlayerBehavior>()?.SavePlayer();
        }
示例#3
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var session = actionInput.Session;

            if (session == null)
            {
                return;                  // This action only makes sense for player sessions.
            }
            var userControlledBehavior = player.FindBehavior <UserControlledBehavior>();

            userControlledBehavior.SecurityRoles |= role;

            var ob = new OutputBuilder();

            ob.AppendLine($"{player.Name} has been granted the {role.ToString()} role.");
            ob.AppendLine($"{player.Name} is now: {userControlledBehavior.SecurityRoles}.");
            session.Write(ob);

            ob.Clear();
            ob.AppendLine($"You have been granted the {role.ToString()} role.");
            userControlledBehavior.Session.Write(ob);

            player.FindBehavior <PlayerBehavior>()?.SavePlayer();
        }
示例#4
0
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityRoles.Administrator)]
        public async Task <DataTablesResponse> GetRolesDataTable(DataTablesModel model, SecurityRole securityRole)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                var users = context.UserRoles
                            .Include(x => x.User)
                            .Include(x => x.Role)
                            .Where(x => x.Role.Name == securityRole.ToString())
                            .Select(x => new RoleModel
                {
                    RoleName = x.Role.Name,
                    UserName = x.User.UserName
                });

                return(await users.GetDataTableResultNoLockAsync(model));
            }
        }