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"); }
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"); }
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; }
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; }
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; }