public async Task <IActionResult> PutAuthGroup(int id, AuthGroup authGroup)
        {
            if (id != authGroup.AuthGroupId)
            {
                return(BadRequest());
            }

            _context.Entry(authGroup).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuthGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <AuthGroup> > PostAuthGroup(AuthGroup authGroup)
        {
            _context.AuthGroup.Add(authGroup);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAuthGroup", new { id = authGroup.AuthGroupId }, authGroup));
        }
Exemplo n.º 3
0
        void OnAuthGroupRemoveCommand(BasePlayer player, string groupName, string[] args)
        {
            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            if (args.Length == 0)
            {
                PendingInteractions.Add(player.UserIDString, new RemoveEntityFromGroup(player, group));
                SendReply(player, Messages.SelectEntityToRemoveFromGroup, group.Name);
                return;
            }

            var        playerName = args[0].Trim();
            BasePlayer member     = BasePlayerEx.FindByNameOrId(playerName);

            if (member == null)
            {
                SendReply(player, Messages.NoSuchPlayer, playerName);
                return;
            }

            if (!group.HasMember(member))
            {
                SendReply(player, Messages.CannotRemoveMemberNotMemberOfGroup, member.displayName, group.Name);
                return;
            }

            group.RemoveMember(member);
            SendReply(player, Messages.MemberRemoved, member.displayName, group.Name);
        }
Exemplo n.º 4
0
        public AuthInfo GetAppMenuByRole(AuthRole role, int pageType = (int)TmpType.小程序专业模板, string accessUrl = null)
        {
            if (role == null)
            {
                return(new AuthInfo());
            }

            AuthGroup group = AuthGroupBLL.SingleModel.GetModel(role.GroupId);

            if (group == null)
            {
                return(new AuthInfo());
            }

            AuthInfo authInfo = new AuthInfo
            {
                AuthMenu  = group.GetAuthMenu(),
                AuthName  = role.Name,
                AuthAdmin = role,
                AllMenu   = NavMenuBLL.SingleModel.GetListByPageType(pageType) ?? new List <NavMenu>(),
                CurrRoute = accessUrl,
            };

            return(authInfo);
        }
Exemplo n.º 5
0
        public IActionResult Edit([Bind("Name,Id", "Version")] AuthGroup authGroup)
        {
            //if (id != authGroup.Id) return NotFound();

            if (!ModelState.IsValid)
            {
                return(View(authGroup));
            }
            try
            {
                authGroup.ModifiedBy = User.Identity.Name;

                Context.AuthGroups.Update(authGroup);
                Context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuthGroupExists(authGroup.Id))
                {
                    return(NotFound());
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public IActionResult Create(CreateGroupViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var authGroup = new AuthGroup
            {
                Name       = model.Name,
                Author     = User.Identity.Name,
                ModifiedBy = User.Identity.Name
            };

            try
            {
                Context.AuthGroups.Add(authGroup);
                Context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError(string.Empty, "The group already exists.");
            }

            return(View(model));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> EditAsync([FromBody] AuthGroup input)
        {
            await _business.EditModel(input);

            return(Ok(new MsgResultDto {
                Success = true
            }));
        }
Exemplo n.º 8
0
        void OnAuthGroupShowCommand(BasePlayer player, string groupName)
        {
            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            var sb = new StringBuilder();

            sb.Append($"Auth group <color=#ffd479>{group.Name}</color> ");

            if (group.Entities.Count == 0)
            {
                sb.AppendLine("isn't managing any items.");
            }
            else
            {
                sb.AppendLine($"is managing <color=#ffd479>{group.Entities.Count}</color> items:");
            }

            var cupboards = group.GetAllManagedEntitiesOfType <ManagedToolCupboard>();

            if (cupboards.Length > 0)
            {
                sb.AppendLine($"  <color=#ffd479>{cupboards.Length}</color> tool cupboard(s)");
            }

            var turrets = group.GetAllManagedEntitiesOfType <ManagedAutoTurret>();

            if (turrets.Length > 0)
            {
                sb.AppendLine($"  <color=#ffd479>{turrets.Length}</color> turret(s)");
            }

            var codeLocks = group.GetAllManagedEntitiesOfType <ManagedCodeLock>();

            if (codeLocks.Length > 0)
            {
                sb.AppendLine($"  <color=#ffd479>{codeLocks.Length}</color> code lock(s)");
            }

            sb.AppendLine($"Owner: {FormatPlayerName(group.OwnerId)}");

            if (group.ManagerIds.Count > 0)
            {
                sb.Append($"<color=#ffd479>{group.ManagerIds.Count}</color> managers: ");
                sb.AppendLine(String.Join(", ", group.ManagerIds.Select(FormatPlayerName).ToArray()));
            }

            sb.Append($"<color=#ffd479>{group.MemberIds.Count}</color> members: ");
            sb.AppendLine(String.Join(", ", group.MemberIds.Select(FormatPlayerName).ToArray()));

            SendReply(player, sb.ToString());
        }
Exemplo n.º 9
0
        /// <summary>
        /// 编辑信息
        /// </summary>
        public async Task EditModel(AuthGroup input)
        {
            if (input.GroupId > 0)
            {
                await _dbContext.Updateable(input).ExecuteCommandAsync();

                return;
            }
            await _dbContext.Insertable(input).ExecuteCommandAsync();
        }
Exemplo n.º 10
0
        public ActionResult Group(AuthInfo authInfo = null, int?aId = null, int?groupId = null)
        {
            AuthGroup group = null;

            if (groupId.HasValue)
            {
                group = AuthGroupBLL.SingleModel.GetByAId(aId.Value, groupId: groupId.Value);
            }
            List <NavMenu> menu = authInfo.AllMenu;

            return(View(Tuple.Create(group, menu)));
        }
Exemplo n.º 11
0
        void OnAuthGroupSyncCommand(BasePlayer player, string groupName)
        {
            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            group.SynchronizeAll();
            SendReply(player, Messages.GroupSynchronized, group.Name, group.MemberIds.Count);
        }
Exemplo n.º 12
0
        void OnAuthGroupDeleteCommand(BasePlayer player, string groupName)
        {
            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            Groups.Delete(group);
            SendReply(player, Messages.GroupDeleted, group.Name);
        }
Exemplo n.º 13
0
            public AuthGroup Create(BasePlayer owner, string name)
            {
                if (GetByOwnerOrManager(owner, name) != null)
                {
                    throw new InvalidOperationException($"Player ${owner.userID} is already the manager of an auth group named {name}!");
                }

                var group = new AuthGroup(owner, name);

                Groups.Add(group);

                return(group);
            }
Exemplo n.º 14
0
 partial void auth(IServiceProvider services)
 {
     Auth = new AuthGroup
            (
         source.AddGroup(nameof(Auth), ResourceAccess.AllowAnonymous()),
         new AuthActionFactory(services)
            );
     AuthApi = new AuthApiGroup
               (
         source.AddGroup(nameof(AuthApi), ResourceAccess.AllowAnonymous()),
         new AuthActionFactory(services)
               );
 }
Exemplo n.º 15
0
        void OnAuthGroupCreateCommand(BasePlayer player, string groupName)
        {
            AuthGroup existingGroup = Groups.GetByOwnerOrManager(player, groupName);

            if (existingGroup != null)
            {
                SendReply(player, Messages.CannotCreateGroupOneAlreadyExists, groupName);
                return;
            }

            AuthGroup group = Groups.Create(player, groupName);

            SendReply(player, Messages.GroupCreated, groupName);
        }
Exemplo n.º 16
0
        public AuthInfo GetAuthMenuByRole(int pageType, int roleId, string accessUrl = null)
        {
            AuthRole  role     = GetModel(roleId);
            AuthGroup group    = AuthGroupBLL.SingleModel.GetModel(role.GroupId);
            AuthInfo  authInfo = new AuthInfo
            {
                AuthMenu  = group.GetAuthMenu(),
                AuthName  = role.Name,
                AuthAdmin = role,
                AllMenu   = role != null?NavMenuBLL.SingleModel.GetListByPageType(pageType) : new List <NavMenu>(),
                                CurrRoute = accessUrl,
            };

            return(authInfo);
        }
Exemplo n.º 17
0
        void OnAuthGroupPromoteCommand(BasePlayer player, string groupName, string[] args)
        {
            if (args.Length == 0)
            {
                SendReply(player, "<color=#ffd479>Usage:</color> /ag NAME promote PLAYER");
                return;
            }

            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            var        playerName = args[0].Trim();
            BasePlayer member     = BasePlayerEx.FindByNameOrId(playerName);

            if (member == null)
            {
                SendReply(player, Messages.NoSuchPlayer, playerName);
                return;
            }

            if (!group.HasMember(member))
            {
                SendReply(player, Messages.CannotPromoteNotMemberOfGroup, member.displayName, group.Name);
                return;
            }

            if (group.HasOwner(member))
            {
                SendReply(player, Messages.CannotPromoteIsOwnerOfGroup, member.displayName, group.Name);
                return;
            }

            if (group.HasManager(member))
            {
                SendReply(player, Messages.CannotPromoteAlreadyManagerOfGroup, member.displayName, group.Name);
                return;
            }

            group.Promote(member);
            SendReply(player, Messages.ManagerAdded, member.displayName, group.Name);
        }
Exemplo n.º 18
0
        public void Admin_UpdateAuthGroup()
        {
            using (var httpTest = new HttpTest())
            {
                var mds = new MarketDataService(_cfg);

                var group = new AuthGroup()
                {
                    ID   = 1,
                    Name = "AuthGroupTest"
                };

                var mdq = mds.UpdateAuthGroup(1, group).ConfigureAwait(true).GetAwaiter().GetResult();

                httpTest.ShouldHaveCalledPath($"{_cfg.BaseAddress}v2.1/group/1")
                .WithVerb(HttpMethod.Put)
                .WithContentType("application/x.msgpacklz4")
                .WithHeadersTest()
                .Times(1);
            }
        }
Exemplo n.º 19
0
        public JsonResult UpdateGroup(int?aId = null, AuthGroup updateGroup = null)
        {
            if (updateGroup == null)
            {
                result.msg = "提交数据为空";
                return(Json(result));
            }
            if (updateGroup.Id > 0 && updateGroup.Aid != aId.Value)
            {
                result.msg = "非法操作";
                return(Json(result));
            }
            if (string.IsNullOrWhiteSpace(updateGroup.Name))
            {
                result.msg = "名称不能为空";
                return(Json(result));
            }
            if (AuthGroupBLL.SingleModel.CheckGroupName(updateGroup.Name, aId.Value, updateGroup.Id))
            {
                result.msg = $"名称为[{updateGroup.Name}]的分组已存在,请选择其它名称";
                return(Json(result));
            }
            bool isSuccess = false;

            if (updateGroup.Id > 0)
            {
                isSuccess = AuthGroupBLL.SingleModel.Update(updateGroup);
            }
            else
            {
                updateGroup.Aid     = aId.Value;
                updateGroup.AddTime = DateTime.Now;
                isSuccess           = int.Parse(AuthGroupBLL.SingleModel.Add(updateGroup).ToString()) > 0;
            }
            result.code = isSuccess ? 1 : 0;
            return(Json(result));
        }
Exemplo n.º 20
0
 public AddEntityToGroup(BasePlayer player, AuthGroup group)
     : base(player, group)
 {
 }
Exemplo n.º 21
0
        /// <summary>
        /// Update an Authorization Group
        /// </summary>
        /// <param name="groupID">The entity Identifier</param>
        /// <param name="group">The entity to update</param>
        /// <param name="ctk">CancellationToken</param>
        /// <returns>Auth Group entity</returns>
        public Task <AuthGroup> UpdateAuthGroup(int groupID, AuthGroup group, CancellationToken ctk = default)
        {
            var url = "/group".AppendPathSegment(groupID);

            return(_client.Exec <AuthGroup, AuthGroup>(HttpMethod.Put, url, group));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Create a new Authorization Group
        /// </summary>
        /// <param name="group">The entity we are going to insert</param>
        /// <param name="ctk">CancellationToken</param>
        /// <returns>Auth Group entity</returns>
        public Task <AuthGroup> CreateAuthGroup(AuthGroup group, CancellationToken ctk = default)
        {
            var url = "/group";

            return(_client.Exec <AuthGroup, AuthGroup>(HttpMethod.Post, url, group));
        }
Exemplo n.º 23
0
 public RemoveEntityFromGroup(BasePlayer player, AuthGroup group)
     : base(player, group)
 {
 }
Exemplo n.º 24
0
 public void Delete(AuthGroup group)
 {
     group.DeauthorizeAll();
     Groups.Remove(group);
 }
        public async Task <IActionResult> Register(RegisterModel model)
        {
            string errorMessage = string.Empty;

            try
            {
                var apiSecQCall               = new ApiCallerSecurityQuestions(_apiUrl.SSAuth);
                var SecurityQuestionsList     = apiSecQCall.GetAllSecurityQuestions();
                var SecurityQuestionModelList = from secQuestion in SecurityQuestionsList
                                                select new QuestionsModel()
                {
                    Id = secQuestion.SecurityQuestionId.ToString(), Name = secQuestion.Question
                };
                ViewBag.QuestionList = SecurityQuestionModelList.ToList();

                // Get Auth Group by name
                var       apiCall         = new ApiCallerAuthGroup(_apiUrl.SSAuth);
                AuthGroup authGroupResult = apiCall.GetAuthGroupByGroupName("NP");

                // Get Role by name
                var  apiCallRole = new ApiCallerRole(_apiUrl.SSAuth);
                Role roleResult  = apiCallRole.GetRoleByName("Admin");

                var userInfoObject = new AuthUser()
                {
                    AuthGroupId = authGroupResult.AuthGroupId,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    Email       = model.Email,
                    LoginId     = model.Email,
                    Password    = model.Password,
                    Status      = "A",
                    UserAdded   = "Admin@SS",
                    UserRole    = new List <UserRole>
                    {
                        new UserRole()
                        {
                            RoleId    = roleResult.RoleId,
                            UserAdded = "Admin@SS"
                        }
                    },
                    UserSecurityQuestion = new List <UserSecurityQuestion>
                    {
                        new UserSecurityQuestion()
                        {
                            SecurityQuestionId = model.Question1,
                            Answer             = model.Answer1,
                            UserAdded          = "Admin@SS"
                        },
                        new UserSecurityQuestion()
                        {
                            SecurityQuestionId = model.Question2,
                            Answer             = model.Answer2,
                            UserAdded          = "Admin@SS"
                        },
                        new UserSecurityQuestion()
                        {
                            SecurityQuestionId = model.Question3,
                            Answer             = model.Answer3,
                            UserAdded          = "Admin@SS"
                        }
                    }
                };

                // Register User
                var apiAuth    = new ApiCallerAuthUser(_apiUrl.SSAuth);
                var userResult = apiAuth.RegisterUser(userInfoObject);

                // Add Organization
                var apiOrg    = new ApiCallerOrganization(_apiUrl.SSChurch);
                var orgResult = apiOrg.PostAddOrganization(new Organization
                {
                    Name       = model.OrganizationName,
                    IndustryId = model.IndustryId,
                    Phone      = model.OrgPhone,
                    Email      = model.OrgEmail,
                    UserAdded  = "Admin@SS"
                });

                // Add User Org
                var apiUserOrg    = new ApiCallerUserOrganization(_apiUrl.SSChurch);
                var userOrgResult = apiUserOrg.PostAddUserOrganization(new UserOrganization
                {
                    OrganizationId = orgResult.OrganizationId,
                    AuthUserId     = userResult.AuthUserId,
                    UserAdded      = "Admin@SS"
                });

                // Handle Claims
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.NameIdentifier, model.Email),
                    new Claim(ClaimTypes.Name, string.Concat(model.FirstName, model.LastName)),
                    new Claim(ClaimTypes.Surname, model.LastName),
                    new Claim(ClaimTypes.GivenName, model.FirstName),
                    new Claim(ClaimTypes.Email, model.Email),
                    new Claim(ClaimTypes.Role, "Admin"),
                    new Claim("OrganizationName", model.OrganizationName),
                    new Claim("OrganizationId", orgResult.OrganizationId.ToString())
                };

                var identity  = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                var principal = new ClaimsPrincipal(identity);

                await HttpContext.SignInAsync(principal);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            ViewBag.ErrorMessage = errorMessage;
            if (!string.IsNullOrEmpty(errorMessage))
            {
                return(View("Register"));
            }
            else
            {
                return(RedirectToAction("Display", "Dashboard"));
            }
        }
Exemplo n.º 26
0
        public byte[] GetBytes()
        {
            using (MemoryStream headerStream = new MemoryStream(), dataStream = new MemoryStream())
            {
                BinaryWriter headerBaos = new BinaryWriter(headerStream);
                BinaryWriter dataBaos   = new BinaryWriter(dataStream);

                try
                {
                    // Version
                    headerBaos.Write(ByteUtils.ShortToBytes(_version));

                    // Id
                    int len = Id.GetLengthOrZero();
                    headerBaos.Write((byte)(len & 0xff));
                    if (len > 0)
                    {
                        dataBaos.Write(Id.GetBytesOrEmptyArray());
                    }

                    // Tag
                    len = Tag.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(Tag.GetBytesOrEmptyArray());
                    }

                    // GroupId
                    len = GroupId.GetLengthOrZero();
                    headerBaos.Write((byte)(len & 0xff));
                    if (len > 0)
                    {
                        dataBaos.Write(GroupId.GetBytesOrEmptyArray());
                    }

                    // SequenceNumber
                    if (SequenceNumber == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)4);
                        dataBaos.Write(ByteUtils.IntegerToBytes(SequenceNumber));
                    }

                    // SequenceTotal
                    if (SequenceTotal == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)4);
                        dataBaos.Write(ByteUtils.IntegerToBytes(SequenceTotal));
                    }

                    // Priority
                    if (Priority == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)1);
                        dataBaos.Write(Priority);
                    }

                    //Timestamp
                    if (Timestamp == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)8);
                        dataBaos.Write(ByteUtils.LongToBytes(Timestamp));
                    }

                    // Publisher
                    len = Publisher.GetLengthOrZero();
                    headerBaos.Write((byte)(len & 0xff));
                    if (len > 0)
                    {
                        dataBaos.Write(Publisher.GetBytesOrEmptyArray());
                    }

                    // AuthId
                    len = AuthId.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(AuthId.GetBytesOrEmptyArray());
                    }

                    // AuthGroup
                    len = AuthGroup.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(AuthGroup.GetBytesOrEmptyArray());
                    }

                    // ChainPosition
                    if (ChainPosition == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)8);
                        dataBaos.Write(ByteUtils.LongToBytes(ChainPosition));
                    }

                    // Hash
                    len = Hash.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(Hash.GetBytesOrEmptyArray());
                    }

                    // PreviousHash
                    len = PreviousHash.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(PreviousHash.GetBytesOrEmptyArray());
                    }

                    // Nonce
                    len = Nonce.GetLengthOrZero();
                    headerBaos.Write(ByteUtils.ShortToBytes((short)(len & 0xffff)));
                    if (len > 0)
                    {
                        dataBaos.Write(Nonce.GetBytesOrEmptyArray());
                    }

                    // DifficultyTarget
                    if (DifficultyTarget == 0)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write((byte)4);
                        dataBaos.Write(ByteUtils.IntegerToBytes(DifficultyTarget));
                    }

                    // InfoType
                    len = InfoType.GetLengthOrZero();
                    headerBaos.Write((byte)(len & 0xff));
                    if (len > 0)
                    {
                        dataBaos.Write(InfoType.GetBytesOrEmptyArray());
                    }

                    // InfoFormat
                    len = InfoFormat.GetLengthOrZero();
                    headerBaos.Write((byte)(len & 0xff));
                    if (len > 0)
                    {
                        dataBaos.Write(InfoFormat.GetBytesOrEmptyArray());
                    }

                    // ContextData
                    if (ContextData == null)
                    {
                        headerBaos.Write((byte)0);
                    }
                    else
                    {
                        headerBaos.Write(ByteUtils.IntegerToBytes(ContextData.Length));
                        dataBaos.Write(ContextData, 0, ContextData.Length);
                    }

                    // ContentData
                    if (ContentData == null)
                    {
                        headerBaos.Write(ByteUtils.IntegerToBytes(0));
                    }
                    else
                    {
                        headerBaos.Write(ByteUtils.IntegerToBytes(ContentData.Length));
                        dataBaos.Write(ContentData, 0, ContentData.Length);
                    }

                    var headerBytes = headerStream.ToArray();
                    var dataBytes   = dataStream.ToArray();

                    var result = new byte[headerBytes.Length + dataBytes.Length];
                    Array.Copy(headerBytes, 0, result, 0, headerBytes.Length);
                    Array.Copy(dataBytes, 0, result, headerBytes.Length, dataBytes.Length);

                    return(result);
                }
                catch (Exception)
                {
                    //TODO: log
                }
                finally
                {
                    try
                    {
                        headerBaos.Dispose();
                        dataBaos.Dispose();
                    }
                    catch (Exception)
                    {
                        // TODO: log("Error when closing byte arrays streams");
                    }
                }
            }

            return(new byte[0]);
        }
Exemplo n.º 27
0
        void OnAuthGroupCodeLocksCommand(BasePlayer player, string groupName, string[] args)
        {
            string command = (args.Length == 0) ? null : args[0].ToLowerInvariant();

            if (command == null)
            {
                OnAuthGroupCodeLocksHelpCommand(player);
                return;
            }

            AuthGroup group = Groups.GetByOwnerOrManager(player, groupName);

            if (group == null)
            {
                SendReply(player, Messages.YouAreNotOwnerOrManagerOfGroup, groupName);
                return;
            }

            var codeLocks = group.GetAllManagedEntitiesOfType <ManagedCodeLock>();

            if (codeLocks.Length == 0)
            {
                SendReply(player, Messages.CannotSendLocksCommandNoLocksInGroup, group.Name);
                return;
            }

            string code = (args.Length < 2) ? null : args[1].Trim();

            switch (command)
            {
            case "code":
                if (code == null || code.Length != 4)
                {
                    OnAuthGroupCodeLocksHelpCommand(player);
                    break;
                }
                foreach (ManagedCodeLock codeLock in codeLocks)
                {
                    codeLock.SetCode(code);
                }
                SendReply(player, Messages.AllLocksCodeChanged, group.Name);
                break;

            case "guestcode":
                if (code == null || code.Length != 4)
                {
                    OnAuthGroupCodeLocksHelpCommand(player);
                    break;
                }
                foreach (ManagedCodeLock codeLock in codeLocks)
                {
                    codeLock.SetGuestCode(code);
                }
                SendReply(player, Messages.AllLocksGuestCodeChanged, group.Name);
                break;

            case "lock":
                foreach (ManagedCodeLock codeLock in codeLocks)
                {
                    codeLock.SetIsLocked(true);
                }
                SendReply(player, Messages.AllLocksLocked, group.Name);
                break;

            case "unlock":
                foreach (ManagedCodeLock codeLock in codeLocks)
                {
                    codeLock.SetIsLocked(false);
                }
                SendReply(player, Messages.AllLocksUnlocked, group.Name);
                break;

            default:
                OnAuthGroupTurretsHelpCommand(player);
                break;
            }
        }
Exemplo n.º 28
0
 public Task <AuthGroup> UpdateAuthGroup(int groupID, AuthGroup group, CancellationToken ctk = default)
 {
     throw new NotImplementedException();
 }