From a7e0e1e3697859f630affc945ddb1539484fbeb1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 15 Aug 2025 03:26:15 +0800 Subject: [PATCH] :lipstick: Update path param --- DysonNetwork.Pass/Account/AccountCurrentController.cs | 8 +++++--- DysonNetwork.Pass/Account/AccountService.cs | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountCurrentController.cs b/DysonNetwork.Pass/Account/AccountCurrentController.cs index 5cec791..3bc1866 100644 --- a/DysonNetwork.Pass/Account/AccountCurrentController.cs +++ b/DysonNetwork.Pass/Account/AccountCurrentController.cs @@ -544,14 +544,15 @@ public class AccountCurrentController( } } - [HttpPatch("devices/{id}/label")] - public async Task> UpdateDeviceLabel(string id, [FromBody] string label) + [HttpPatch("devices/{deviceId}/label")] + [Authorize] + public async Task> UpdateDeviceLabel(string deviceId, [FromBody] string label) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); try { - await accounts.UpdateDeviceName(currentUser, id, label); + await accounts.UpdateDeviceName(currentUser, deviceId, label); return NoContent(); } catch (Exception ex) @@ -561,6 +562,7 @@ public class AccountCurrentController( } [HttpPatch("devices/current/label")] + [Authorize] public async Task> UpdateCurrentDeviceLabel([FromBody] string label) { if (HttpContext.Items["CurrentUser"] is not Account currentUser || diff --git a/DysonNetwork.Pass/Account/AccountService.cs b/DysonNetwork.Pass/Account/AccountService.cs index 3435f8b..9d03ac9 100644 --- a/DysonNetwork.Pass/Account/AccountService.cs +++ b/DysonNetwork.Pass/Account/AccountService.cs @@ -464,7 +464,9 @@ public class AccountService( public async Task UpdateDeviceName(Account account, string deviceId, string label) { - var device = await db.AuthClients.FirstOrDefaultAsync(d => d.DeviceId == deviceId && d.AccountId == account.Id); + var device = await db.AuthClients.FirstOrDefaultAsync( + c => c.DeviceId == deviceId && c.AccountId == account.Id + ); if (device is null) throw new InvalidOperationException("Device was not found."); device.DeviceLabel = label; @@ -508,7 +510,9 @@ public class AccountService( public async Task DeleteDevice(Account account, string deviceId) { - var device = await db.AuthClients.FirstOrDefaultAsync(c => c.DeviceId == deviceId && c.AccountId == account.Id); + var device = await db.AuthClients.FirstOrDefaultAsync( + c => c.DeviceId == deviceId && c.AccountId == account.Id + ); if (device is null) throw new InvalidOperationException("Device not found.");