From a27bda4720b0e253a22dcd38d1c336a6ae619eb5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 15 Aug 2025 12:10:59 +0800 Subject: [PATCH] :bug: Fix web didn't has device name --- DysonNetwork.Pass/Auth/AuthController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/DysonNetwork.Pass/Auth/AuthController.cs b/DysonNetwork.Pass/Auth/AuthController.cs index 0cf2894..4bd7be4 100644 --- a/DysonNetwork.Pass/Auth/AuthController.cs +++ b/DysonNetwork.Pass/Auth/AuthController.cs @@ -20,12 +20,12 @@ public class AuthController( ) : ControllerBase { private readonly string _cookieDomain = configuration["AuthToken:CookieDomain"]!; - + public class ChallengeRequest { [Required] public ClientPlatform Platform { get; set; } - [Required] [MaxLength(256)] public string Account { get; set; } = null!; - [Required] [MaxLength(512)] public string DeviceId { get; set; } = null!; + [Required][MaxLength(256)] public string Account { get; set; } = null!; + [Required][MaxLength(512)] public string DeviceId { get; set; } = null!; [MaxLength(1024)] public string? DeviceName { get; set; } public List Audiences { get; set; } = new(); public List Scopes { get; set; } = new(); @@ -48,6 +48,8 @@ public class AuthController( var ipAddress = HttpContext.Connection.RemoteIpAddress?.ToString(); var userAgent = HttpContext.Request.Headers.UserAgent.ToString(); + request.DeviceName ??= userAgent; + // Trying to pick up challenges from the same IP address and user agent var existingChallenge = await db.AuthChallenges .Where(e => e.AccountId == account.Id) @@ -295,4 +297,4 @@ public class AuthController( }); return Ok(); } -} \ No newline at end of file +}