hotfix: fix Blazor circuit crash on Discord link + add missing avatar_url column
- Replace @onclick button with plain <a href="/auth/discord"> to avoid circuit disconnect from forceLoad navigation during event handlers. - Add query param handling (?linked, ?link_error) in Profile.razor for Discord callback feedback. - Add V021 migration: ALTER TABLE players ADD COLUMN avatar_url. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
-- =============================================================
|
||||||
|
-- V021: Add avatar_url column to players table
|
||||||
|
-- =============================================================
|
||||||
|
-- Scope: Support storing avatar URLs for Discord and other platforms.
|
||||||
|
-- =============================================================
|
||||||
|
|
||||||
|
ALTER TABLE players
|
||||||
|
ADD COLUMN avatar_url VARCHAR(500);
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
@using Microsoft.AspNetCore.Components.Authorization
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@inject ISessionStore SessionStore
|
@inject ISessionStore SessionStore
|
||||||
@inject NavigationManager Navigation
|
|
||||||
|
|
||||||
<PageTitle>Профиль — GM-Relay</PageTitle>
|
<PageTitle>Профиль — GM-Relay</PageTitle>
|
||||||
|
|
||||||
@@ -54,9 +53,9 @@
|
|||||||
<h2 class="section-title">Добавить аккаунт</h2>
|
<h2 class="section-title">Добавить аккаунт</h2>
|
||||||
@if (!HasLinkedPlatform("Discord"))
|
@if (!HasLinkedPlatform("Discord"))
|
||||||
{
|
{
|
||||||
<button class="btn btn-primary" @onclick="LinkDiscord">
|
<a href="/auth/discord" class="btn btn-primary">
|
||||||
Привязать Discord
|
Привязать Discord
|
||||||
</button>
|
</a>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -86,6 +85,12 @@
|
|||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
|
private Task<AuthenticationState>? AuthenticationStateTask { get; set; }
|
||||||
|
|
||||||
|
[SupplyParameterFromQuery]
|
||||||
|
public string? Linked { get; set; }
|
||||||
|
|
||||||
|
[SupplyParameterFromQuery(Name = "link_error")]
|
||||||
|
public string? LinkError { get; set; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (AuthenticationStateTask is not null)
|
if (AuthenticationStateTask is not null)
|
||||||
@@ -99,6 +104,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(Linked))
|
||||||
|
{
|
||||||
|
successMessage = $"{Linked} аккаунт успешно привязан!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(LinkError))
|
||||||
|
{
|
||||||
|
errorMessage = $"Ошибка привязки: {Uri.UnescapeDataString(LinkError)}";
|
||||||
|
}
|
||||||
|
|
||||||
await LoadIdentities();
|
await LoadIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +172,4 @@
|
|||||||
isUnlinking = false;
|
isUnlinking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LinkDiscord()
|
|
||||||
{
|
|
||||||
Navigation.NavigateTo("/auth/discord", forceLoad: true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user