Added notice to UserView when profile is not public

This commit is contained in:
Mia Rose Winter 2024-02-19 00:11:53 +01:00
parent 7a9715977a
commit 9d528dc8f2
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
3 changed files with 10 additions and 3 deletions

View file

@ -1,11 +1,11 @@
@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 Wave.Utilities
@using System.Security.Claims
@inject IDbContextFactory<ApplicationDbContext> ContextFactory @inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<UserView> Localizer @inject IStringLocalizer<UserView> Localizer
@inject IMessageDisplay Message
<PageTitle>@(TitlePrefix + @Localizer["Title"] + " | " + (User?.FullName ?? Localizer["NotFound_Title"]))</PageTitle> <PageTitle>@(TitlePrefix + @Localizer["Title"] + " | " + (User?.FullName ?? Localizer["NotFound_Title"]))</PageTitle>
@ -74,10 +74,11 @@
.ThenInclude(a => a.Categories) .ThenInclude(a => a.Categories)
.FirstOrDefaultAsync(u => u.Id == Id.ToString()); .FirstOrDefaultAsync(u => u.Id == Id.ToString());
} }
// 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 if (User is not null && HttpContext.User.FindFirst("Id")?.Value == User.Id) {
Message.ShowWarning(Localizer["ProfileNotPublic_Message"]);
} else { } else {
User = null; User = null;
} }

View file

@ -116,4 +116,7 @@
<data name="Articles" xml:space="preserve"> <data name="Articles" xml:space="preserve">
<value>Artikel</value> <value>Artikel</value>
</data> </data>
<data name="ProfileNotPublic_Message" xml:space="preserve">
<value>Ihr Profil ist momentan nicht öffentlich einsehbar. </value>
</data>
</root> </root>

View file

@ -116,4 +116,7 @@
<data name="Articles" xml:space="preserve"> <data name="Articles" xml:space="preserve">
<value>Articles</value> <value>Articles</value>
</data> </data>
<data name="ProfileNotPublic_Message" xml:space="preserve">
<value>Your profile is currently not publicly visible.</value>
</data>
</root> </root>