예제 #1
0
 private void ValidateInvation(RoomSecurityRule rule, ApplicationUser user)
 {
     logger.LogDebug("validating invite rule");
     if (!rule.Data.Split('\n').Contains(user.Id))
     {
         throw new StatusCodeException(StatusCode.AccessDenied);
     }
     logger.LogDebug("success validated invite rule");
 }
예제 #2
0
 private void ValidatePassword(RoomSecurityRule securityRule, string password)
 {
     //TODO Использовать хэши!!!
     logger.LogDebug($"validating password");
     if (securityRule.Data != password)
     {
         throw new StatusCodeException(StatusCode.IncorrectRoomPassword);
     }
     logger.LogDebug($"success validated password");
 }
예제 #3
0
        public void CreatePublicRule(Room room)
        {
            logger.LogDebug($"create public rule for room {room.Id} {room.Name}");

            var publicRule = new RoomSecurityRule()
            {
                PrivacyRule = PrivacyRoomType.Public
            };

            room.SecurityRule = publicRule;
        }
예제 #4
0
        public void CreatePasswordRule(Room room, string password)
        {
            logger.LogDebug($"create password rule for room {room.Name}");

            if (password?.Length != 6 || !int.TryParse(password, out _))
            {
                throw new StatusCodeException(StatusCode.IncorrectRoomPassword);
            }

            RoomSecurityRule rule = new RoomSecurityRule()
            {
                PrivacyRule = PrivacyRoomType.Password,
                Data        = password //TODO Использовать хеш!!!
            };

            room.SecurityRule = rule;
        }
예제 #5
0
        public void CreateInvationRule(Room room, Guid[] usersIds)
        {
            logger.LogDebug($"creating invation rule");
            if ((usersIds?.Length ?? 0) == 0)
            {
                throw new StatusCodeException(StatusCode.EmptyInvationRoom);
            }
            var inviteRule = new RoomSecurityRule()
            {
                PrivacyRule = PrivacyRoomType.InvationPrivate
            };

            var userIdsString = string.Join("\n", usersIds.Select(I => I.ToString()));

            inviteRule.Data = userIdsString;

            room.SecurityRule = inviteRule;
        }