Пример #1
0
        public async Task DontTrustThisRole(string roleName, Contexts contexts)
        {
            var query           = new GetServerTrustedRolesQuery(contexts.Server.Id);
            var trustedRolesIds = this._queryBus.Execute(query).TrustedRolesIds;
            var role            = this._usersRolesService.GetRoleByName(roleName, contexts.Server);
            var messagesService = this._messagesServiceFactory.Create(contexts);

            if (role == null)
            {
                throw new RoleNotFoundException(roleName);
            }
            if (!trustedRolesIds.Contains(role.Id))
            {
                await messagesService.SendResponse(x => x.RoleAlreadyIsUntrusted(roleName));

                return;
            }
            var command = new SetRoleAsUntrustedCommand(role.Id, contexts.Server.Id);

            await this._commandBus.ExecuteAsync(command);

            await messagesService.SendResponse(x => x.RoleSetAsUntrusted(roleName));

            await this._checkUserSafetyService.Refresh();
        }
Пример #2
0
        public Task StopTrustingRole(UserRole role)
        {
            var command = new SetRoleAsUntrustedCommand(role.Id, role.ServerId);

            return(this._commandBus.ExecuteAsync(command));
        }