Implemented Login workflow

This commit is contained in:
2025-11-30 15:19:49 +01:00
parent 2b5b0c1067
commit 825bd80ef0
22 changed files with 330 additions and 56 deletions

View File

@@ -4,7 +4,11 @@ using SpotiParty.Web.Services;
namespace SpotiParty.Web.Components.Pages;
public partial class EnqueuePage(AuthorizationHandler authHandler) : ComponentBase {
public partial class EnqueuePage(AuthorizationHandler authHandler, NavigationManager navigator) : ComponentBase {
[Parameter]
public string UserId { get; set; } = string.Empty;
private readonly int _currentYear = DateTime.Now.Year;
private SpotifyClient _client = null!;
@@ -17,7 +21,20 @@ public partial class EnqueuePage(AuthorizationHandler authHandler) : ComponentBa
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
_client = await authHandler.ConfigureClient();
if (!Guid.TryParse(UserId, out var guid)) {
navigator.NavigateTo("/", forceLoad: true);
return;
}
var client = await authHandler.ConfigureClient(guid);
if (client is null) {
navigator.NavigateTo("/", forceLoad: true);
return;
}
_client = client;
}
private async Task ExecuteSearch() {
@@ -51,9 +68,8 @@ public partial class EnqueuePage(AuthorizationHandler authHandler) : ComponentBa
private async Task DialogAccept() {
if (_selectedTrack is null || _isAdding) return;
_isAdding = true;
/*var request = new PlayerAddToQueueRequest(_selectedTrack.Uri);
await _client.Player.AddToQueue(request);*/
await Task.Delay(3000); //TODO: Simulate adding
var request = new PlayerAddToQueueRequest(_selectedTrack.Uri);
await _client.Player.AddToQueue(request);
_isAdding = false;
_success = true;