@page "/profile/{id:guid}" @using Wave.Data @using Microsoft.EntityFrameworkCore @using Microsoft.Extensions.Options @using Wave.Utilities @inject NavigationManager Navigation @inject IDbContextFactory ContextFactory @inject IOptions Customizations @inject IOptions Features @inject IStringLocalizer Localizer @inject IMessageDisplay Message @if (User is not null) { @if (Features.Value.Rss) { } } @if (User is null) { } @($"{(User?.FullName ?? Localizer["NotFound_Title"])} {TitlePostfix}") @if (User is null) {

@Localizer["NotFound_Title"]

@Localizer["NotFound_Description"]

@Localizer["NotFound_BackToHome_Label"] } else {

@Localizer["Title"]

@User.Name

@User.AboutTheAuthor

@foreach (var link in User.Links) { }

@if (!string.IsNullOrWhiteSpace(User.Biography)) {

@Localizer["Biography"]

@((MarkupString) User.BiographyHtml)

}

@Localizer["Articles"]

} @code { [CascadingParameter(Name = "TitlePostfix")] private string TitlePostfix { get; set; } = default!; [CascadingParameter] public required HttpContext HttpContext { get; set; } [Parameter] public Guid? Id { get; set; } private ApplicationUser? User { get; set; } protected override async Task OnInitializedAsync() { if (User is not null) return; await using var context = await ContextFactory.CreateDbContextAsync(); // Find user if (Id is not null) { var now = DateTimeOffset.UtcNow; User = await context.Users .IgnoreAutoIncludes().IgnoreQueryFilters() .Include(u => u.Articles .Where(a => !a.IsDeleted && a.Status == ArticleStatus.Published && a.PublishDate <= now)) .ThenInclude(a => a.Categories) .AsSplitQuery() .FirstOrDefaultAsync(u => u.Id == Id.ToString()); } // Validate access to user if (User is not null && (User.Articles.Count > 0 || HttpContext.User.IsInRole("Admin"))) { } else if (User is not null && HttpContext.User.FindFirst("Id")?.Value == User.Id) { Message.ShowWarning(Localizer["ProfileNotPublic_Message"]); } else { User = null; } } }