diff --git a/allstarr/Controllers/AdminController.cs b/allstarr/Controllers/AdminController.cs index 4883cfd..9dc9fce 100644 --- a/allstarr/Controllers/AdminController.cs +++ b/allstarr/Controllers/AdminController.cs @@ -76,7 +76,7 @@ public class AdminController : ControllerBase var token = await _spotifyClient.GetWebAccessTokenAsync(); if (!string.IsNullOrEmpty(token)) { - // Try to get user info (may fail even with valid token) + // Try to get user info (may fail even with valid token due to scope limitations) var (success, userId, displayName) = await _spotifyClient.GetCurrentUserAsync(); if (success) { @@ -85,10 +85,10 @@ public class AdminController : ControllerBase } else { - // Token is valid but /me endpoint failed - still consider it authenticated - // (the token being non-anonymous is the real indicator) + // Token is valid but /me endpoint failed - this is normal for TOTP tokens + // which don't have user-read-private scope. Playlists still work fine. spotifyAuthStatus = "authenticated"; - spotifyUser = "(profile not accessible)"; + spotifyUser = "(working - profile scope not available)"; } } else @@ -498,6 +498,36 @@ public class AdminController : ControllerBase return Ok(new { message = "Cache cleared", filesDeleted = clearedFiles }); } + /// + /// Initialize cookie date to current date if cookie exists but date is not set + /// + [HttpPost("config/init-cookie-date")] + public async Task InitCookieDate() + { + // Only init if cookie exists but date is not set + if (string.IsNullOrEmpty(_spotifyApiSettings.SessionCookie)) + { + return BadRequest(new { error = "No cookie set" }); + } + + if (!string.IsNullOrEmpty(_spotifyApiSettings.SessionCookieSetDate)) + { + return Ok(new { message = "Cookie date already set", date = _spotifyApiSettings.SessionCookieSetDate }); + } + + _logger.LogInformation("Initializing cookie date to current date (cookie existed without date tracking)"); + + var updateRequest = new ConfigUpdateRequest + { + Updates = new Dictionary + { + ["SPOTIFY_API_SESSION_COOKIE_SET_DATE"] = DateTime.UtcNow.ToString("o") + } + }; + + return await UpdateConfig(updateRequest); + } + private static string MaskValue(string? value, int showLast = 0) { if (string.IsNullOrEmpty(value)) return "(not set)"; diff --git a/allstarr/wwwroot/index.html b/allstarr/wwwroot/index.html index 8723f0b..3528ea9 100644 --- a/allstarr/wwwroot/index.html +++ b/allstarr/wwwroot/index.html @@ -532,7 +532,6 @@ Name Spotify ID Tracks - Position Cache Age Actions @@ -685,13 +684,6 @@ -
- - -