mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
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:
@@ -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)";
|
||||
|
||||
Reference in New Issue
Block a user