Remove LocalTracksPosition UI, auto-init cookie date tracking

- Removed LocalTracksPosition from playlist table (uses Spotify order now)
- Removed LocalTracksPosition from add playlist modal and JS
- Added /api/admin/config/init-cookie-date endpoint to auto-set date
- Cookie date auto-initializes when cookie exists but date is unknown
- Improved user display message when profile scope unavailable
- TOTP tokens work for playlists but don't have user-read-private scope
This commit is contained in:
2026-02-03 15:00:12 -05:00
parent b7379e2fd4
commit 4036c739a3
2 changed files with 65 additions and 20 deletions

View File

@@ -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 });
}
/// <summary>
/// Initialize cookie date to current date if cookie exists but date is not set
/// </summary>
[HttpPost("config/init-cookie-date")]
public async Task<IActionResult> 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<string, string>
{
["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)";