Improved UserView, now also always visible to yourself
This commit is contained in:
parent
62fec4f748
commit
7a9715977a
|
@ -1,6 +1,8 @@
|
||||||
@page "/profile/{id:guid}"
|
@page "/profile/{id:guid}"
|
||||||
@using Wave.Data
|
@using Wave.Data
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using Wave.Components.Account
|
||||||
|
@using System.Security.Claims
|
||||||
|
|
||||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
||||||
@inject IStringLocalizer<UserView> Localizer
|
@inject IStringLocalizer<UserView> Localizer
|
||||||
|
@ -18,9 +20,9 @@
|
||||||
<div class="shrink-0 md:w-40 lg:w-56">
|
<div class="shrink-0 md:w-40 lg:w-56">
|
||||||
<ProfilePictureComponent ProfileId="@User.Id" Size="400" />
|
<ProfilePictureComponent ProfileId="@User.Id" Size="400" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="flex flex-col">
|
||||||
<h2 class="text-2xl lg:text-4xl mb-3">@User.FullName</h2>
|
<h2 class="text-2xl lg:text-4xl mb-3">@User.Name</h2>
|
||||||
<p class="my-3">@User.AboutTheAuthor</p>
|
<p class="mb-3 flex-1">@User.AboutTheAuthor</p>
|
||||||
<div class="flex gap-2 flex-wrap">
|
<div class="flex gap-2 flex-wrap">
|
||||||
@foreach (var link in User.Links) {
|
@foreach (var link in User.Links) {
|
||||||
<UserLinkComponent Link="link" class="badge hover:badge-outline flex gap-2 p-4" />
|
<UserLinkComponent Link="link" class="badge hover:badge-outline flex gap-2 p-4" />
|
||||||
|
@ -55,12 +57,13 @@
|
||||||
@code {
|
@code {
|
||||||
[CascadingParameter(Name = "TitlePrefix")]
|
[CascadingParameter(Name = "TitlePrefix")]
|
||||||
private string TitlePrefix { get; set; } = default!;
|
private string TitlePrefix { get; set; } = default!;
|
||||||
|
[CascadingParameter]
|
||||||
|
public required HttpContext HttpContext { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
|
|
||||||
private ApplicationUser? User { get; set; }
|
private ApplicationUser? User { get; set; }
|
||||||
private List<Article> Articles { get; set; } = [];
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync() {
|
protected override async Task OnInitializedAsync() {
|
||||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||||
|
@ -74,7 +77,7 @@
|
||||||
|
|
||||||
// Validate access to user
|
// Validate access to user
|
||||||
if (User is not null && User.Articles.Count > 0) {
|
if (User is not null && User.Articles.Count > 0) {
|
||||||
|
} else if (User is not null && HttpContext.User.FindFirst("Id")?.Value == User.Id) {
|
||||||
} else {
|
} else {
|
||||||
User = null;
|
User = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue