Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public partial class AppHub : Hub

public override async Task OnConnectedAsync()
{
CheckClientAppVersion();

if (Context.GetHttpContext()?.ContainsExpiredAccessToken() is true)
throw new HubException(nameof(AppStrings.UnauthorizedException)).WithData("ConnectionId", Context.ConnectionId);

Expand Down Expand Up @@ -97,18 +95,4 @@ private async Task ChangeAuthenticationStateImplementation(ClaimsPrincipal? user
await dbContext.UserSessions.Where(us => us.SignalRConnectionId == Context.ConnectionId).ExecuteUpdateAsync(us => us.SetProperty(x => x.SignalRConnectionId, (string?)null));
}
}

private void CheckClientAppVersion()
{
if (Context.GetHttpContext()?.Request?.Headers?.TryGetValue("X-App-Version", out var appVersionHeaderValue) is true && appVersionHeaderValue.Any())
{
var appVersion = appVersionHeaderValue.Single()!;
var appPlatformType = Enum.Parse<AppPlatformType>(Context.GetHttpContext()!.Request.Headers["X-App-Platform"].Single()!);
var minimumSupportedVersion = settings.SupportedAppVersions!.GetMinimumSupportedAppVersion(appPlatformType);
if (minimumSupportedVersion != null && Version.Parse(appVersion) < minimumSupportedVersion)
throw new HubException(nameof(AppStrings.ForceUpdateTitle))
.WithData("ClientAppVersion", appVersion)
.WithData("ConnectionId", Context.ConnectionId);
}
}
}
Loading