Compare commits
61 Commits
ad6f28023e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78135a9f6d | ||
|
|
231e29f877 | ||
|
|
17a0be20b3 | ||
|
|
2f4823ed09 | ||
|
|
1759e8a2d4 | ||
|
|
865797d3f8 | ||
|
|
cefa47a176 | ||
|
|
c4d7fd6ed5 | ||
|
|
f4f04e4a42 | ||
|
|
6807f2b6e6 | ||
|
|
0dd0c1bf4c | ||
|
|
87f26f9367 | ||
|
|
c0c18f2ddd | ||
|
|
b0866754e0 | ||
|
|
870930914e | ||
|
|
54effa67ac | ||
|
|
48ad7dda87 | ||
|
|
d09926a8b4 | ||
|
|
954d57b7a6 | ||
|
|
781da32796 | ||
|
|
b1ed916da4 | ||
|
|
94a2dbf801 | ||
|
|
dc9276e3e9 | ||
|
|
aba2007481 | ||
|
|
cf4b73735b | ||
|
|
cb3a2ae042 | ||
|
|
8ad6a143de | ||
|
|
46d5bcd00d | ||
|
|
545f59e059 | ||
|
|
cad9617451 | ||
|
|
04084b4bf7 | ||
|
|
69516b2701 | ||
|
|
def8702489 | ||
|
|
8262c4979b | ||
|
|
ad9e2ae8c1 | ||
|
|
4d4648b187 | ||
|
|
f04dba72fd | ||
|
|
03872e8bba | ||
|
|
4330b53824 | ||
|
|
7660e8ce81 | ||
|
|
9da0bf3a43 | ||
|
|
9983a58ba9 | ||
|
|
3db943d652 | ||
|
|
40f0213a73 | ||
|
|
5a4d4a7a04 | ||
|
|
c9d46be196 | ||
|
|
19c22e6ae8 | ||
|
|
d1852f28c8 | ||
|
|
e80d5b92f3 | ||
|
|
62bfdb2023 | ||
|
|
646ccb0f18 | ||
|
|
ac52bc6df9 | ||
|
|
b3212acf6d | ||
|
|
a93de45270 | ||
|
|
c7e0bfd8da | ||
|
|
5f5690e84d | ||
|
|
05b74b929e | ||
|
|
328e194611 | ||
|
|
8a65c03c2c | ||
|
|
297a7c60bd | ||
|
|
8e5a37a0c9 |
@@ -23,6 +23,9 @@ jobs:
|
||||
with:
|
||||
dotnet-version: "9.0.x"
|
||||
|
||||
- name: Run tests
|
||||
run: dotnet test
|
||||
|
||||
- name: Publish server project
|
||||
run: dotnet publish ./FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj -c Release -o ./Publish/Server
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ jobs:
|
||||
with:
|
||||
dotnet-version: "9.0.x"
|
||||
|
||||
- name: Run tests
|
||||
run: dotnet test
|
||||
|
||||
- name: Publish server project
|
||||
run: dotnet publish ./FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj -c Release -o ./Publish/Server
|
||||
|
||||
|
||||
11
.gitignore
vendored
@@ -8,3 +8,14 @@ Publish/
|
||||
app.db
|
||||
FoodsharingSiegen.Server/wwwroot/buildinfo.txt
|
||||
FoodsharingSiegen.Server/config/appsettings.json
|
||||
|
||||
# Generated CSS files from SCSS
|
||||
FoodsharingSiegen.Server/Pages/AuditView.razor.css
|
||||
FoodsharingSiegen.Server/Shared/DefaultLayout.razor.css
|
||||
FoodsharingSiegen.Server/Shared/NavMenu.razor.css
|
||||
FoodsharingSiegen.Server/wwwroot/css/site.css
|
||||
FoodsharingSiegen.Server/wwwroot/css/site.min.css
|
||||
FoodsharingSiegen.Server/wwwroot/css/site.css.map
|
||||
FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css
|
||||
FoodsharingSiegen.Server/Controls/ProspectContainer.razor.css.map
|
||||
FoodsharingSiegen.Server/Shared/DefaultLayout.razor.css.map
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect (ab)
|
||||
/// </summary>
|
||||
public Prospect Prospect { get; set; }
|
||||
public Prospect Prospect { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect id (ab)
|
||||
@@ -74,7 +74,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the user (ab)
|
||||
/// </summary>
|
||||
public User User { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the user id (ab)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the interactions (ab)
|
||||
/// </summary>
|
||||
public IList<Interaction> Interactions { get; set; }
|
||||
public IList<Interaction> Interactions { get; set; } = new List<Interaction>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the memo (ab)
|
||||
@@ -51,7 +51,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the name (ab)
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the state of the record within the system.
|
||||
@@ -63,6 +63,16 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// </summary>
|
||||
public bool Warning { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a token string used to securely authorize upload logic.
|
||||
/// </summary>
|
||||
public Guid? VerificationToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets uploaded identity verification images.
|
||||
/// </summary>
|
||||
public ICollection<ProspectImage>? Images { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
28
FoodsharingSiegen.Contracts/Entity/ProspectImage.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FoodsharingSiegen.Contracts.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an uploaded image for a prospect's verification.
|
||||
/// </summary>
|
||||
public class ProspectImage
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid ProspectId { get; set; }
|
||||
|
||||
[ForeignKey("ProspectId")]
|
||||
public Prospect? Prospect { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte[] ImageData { get; set; } = [];
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string ContentType { get; set; } = string.Empty;
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the encrypted password (ab)
|
||||
/// </summary>
|
||||
public string EncryptedPassword { get; set; }
|
||||
public string EncryptedPassword { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the force logout (ab)
|
||||
@@ -30,7 +30,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the groups (ab)
|
||||
/// </summary>
|
||||
public string Groups { get; set; }
|
||||
public string Groups { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the groups list (ab)
|
||||
@@ -57,12 +57,12 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the interactions (ab)
|
||||
/// </summary>
|
||||
public IList<Interaction> Interactions { get; set; }
|
||||
public IList<Interaction> Interactions { get; set; } = new List<Interaction>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the mail (ab)
|
||||
/// </summary>
|
||||
public string Mail { get; set; }
|
||||
public string Mail { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the memo (ab)
|
||||
@@ -72,7 +72,7 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the name (ab)
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the network (ab)
|
||||
@@ -110,11 +110,6 @@ namespace FoodsharingSiegen.Contracts.Entity
|
||||
/// </summary>
|
||||
public UserType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the verified (ab)
|
||||
/// </summary>
|
||||
public bool Verified { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Method Clone
|
||||
|
||||
@@ -62,7 +62,32 @@ namespace FoodsharingSiegen.Contracts.Enums
|
||||
/// <summary>
|
||||
/// The remove interaction audit type
|
||||
/// </summary>
|
||||
RemoveInteraction = 100
|
||||
RemoveInteraction = 100,
|
||||
|
||||
/// <summary>
|
||||
/// The delete prospect images audit type
|
||||
/// </summary>
|
||||
DeleteProspectImages = 110,
|
||||
|
||||
/// <summary>
|
||||
/// The view prospect images audit type
|
||||
/// </summary>
|
||||
ViewProspectImages = 120,
|
||||
|
||||
/// <summary>
|
||||
/// The upload prospect image audit type
|
||||
/// </summary>
|
||||
UploadProspectImage = 130,
|
||||
|
||||
/// <summary>
|
||||
/// The request password reset audit type
|
||||
/// </summary>
|
||||
RequestPasswordReset = 140,
|
||||
|
||||
/// <summary>
|
||||
/// The change own password audit type
|
||||
/// </summary>
|
||||
ChangeOwnPassword = 150
|
||||
|
||||
#endregion Prospects
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
public bool WithoutIdCheck { get; set; }
|
||||
|
||||
public bool IdCheckPossible { get; set; }
|
||||
|
||||
public bool NoActivity { get; set; }
|
||||
|
||||
public bool RecentActivity { get; set; }
|
||||
|
||||
@@ -2,11 +2,13 @@ using FoodsharingSiegen.Contracts;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Enums;
|
||||
using FoodsharingSiegen.Contracts.Helper;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using FoodsharingSiegen.Shared.Helper;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Auth
|
||||
{
|
||||
@@ -55,6 +57,11 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
/// </summary>
|
||||
private readonly IMailService _mailService;
|
||||
|
||||
/// <summary>
|
||||
/// The application settings
|
||||
/// </summary>
|
||||
private readonly AppSettings _appSettings;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Setup/Teardown
|
||||
@@ -70,12 +77,14 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
FsContext context,
|
||||
LocalStorageService localStorageService,
|
||||
AuthenticationStateProvider authenticationStateProvider,
|
||||
IMailService mailService)
|
||||
IMailService mailService,
|
||||
IOptions<AppSettings> appSettings)
|
||||
{
|
||||
Context = context;
|
||||
_localStorageService = localStorageService;
|
||||
_authenticationStateProvider = authenticationStateProvider;
|
||||
_mailService = mailService;
|
||||
_appSettings = appSettings.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -133,6 +142,12 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
|
||||
if (_user != null)
|
||||
{
|
||||
if (_user.Type == UserType.Unverified)
|
||||
{
|
||||
_user = null;
|
||||
return new OperationResult(new Exception("Anmeldung nicht möglich."));
|
||||
}
|
||||
|
||||
var serializedToken = AuthHelper.CreateToken(_user);
|
||||
await _localStorageService.SetItem(StorageKeys.TokenKey, serializedToken);
|
||||
|
||||
@@ -147,7 +162,7 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
return new OperationResult();
|
||||
}
|
||||
|
||||
return new OperationResult(new Exception("Benutzername oder Passwort falsch"));
|
||||
return new OperationResult(new Exception("E-Mail-Adresse oder Passwort ist ungültig."));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -197,6 +212,34 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
|
||||
#region Password Recovery
|
||||
|
||||
public async Task InitiateInitialPasswordSetup(string email, string baseUri)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(email)) return;
|
||||
|
||||
var user = await Context.Users!.FirstOrDefaultAsync(x => x.Mail.ToLower() == email.ToLower());
|
||||
if (user == null) return; // Do not leak existence
|
||||
|
||||
var resetToken = Guid.NewGuid().ToString("N");
|
||||
user.ResetToken = resetToken;
|
||||
user.ResetTokenExpiry = DateTime.UtcNow.AddDays(7);
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
var resetLink = $"{baseUri.TrimEnd('/')}/reset-password/{resetToken}";
|
||||
var mailBody = $"""
|
||||
Hallo {user.Name},<br>
|
||||
<br>
|
||||
für dich wurde ein neues Konto bei {_appSettings.Terms.Title} erstellt. <br>
|
||||
<br>
|
||||
Um dein Passwort festzulegen, klicke bitte auf den folgenden Link (dieser ist 7 Tage gültig):<br>
|
||||
<a href='{resetLink}'>{resetLink}</a><br>
|
||||
<br>
|
||||
Viele Grüße<br>Dein Team {_appSettings.Terms.Title}
|
||||
""";
|
||||
|
||||
await _mailService.SendEmailAsync(user.Mail, "Passwort festlegen", mailBody);
|
||||
}
|
||||
|
||||
public async Task InitiatePasswordReset(string email, string baseUri)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(email)) return;
|
||||
@@ -208,10 +251,28 @@ namespace FoodsharingSiegen.Server.Auth
|
||||
user.ResetToken = resetToken;
|
||||
user.ResetTokenExpiry = DateTime.UtcNow.AddMinutes(30);
|
||||
|
||||
Context.Audits?.Add(new Audit
|
||||
{
|
||||
Created = DateTime.Now,
|
||||
Type = AuditType.RequestPasswordReset,
|
||||
UserID = user.Id,
|
||||
Data1 = user.Mail
|
||||
});
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
var resetLink = $"{baseUri.TrimEnd('/')}/reset-password/{resetToken}";
|
||||
var mailBody = $"Hallo {user.Name},<br><br>Um dein Passwort zurückzusetzen, klicke bitte auf den folgenden Link (dieser ist 30 Minuten gültig):<br><a href='{resetLink}'>{resetLink}</a><br><br>Viele Grüße<br>Dein Foodsharing Team";
|
||||
var mailBody = $"""
|
||||
Hallo {user.Name},<br>
|
||||
<br>
|
||||
für dein Konto wurde eine Anfrage zum Zurücksetzen des Passworts gestellt. <br>
|
||||
Wenn du diese Anfrage nicht gestellt hast, kannst du diese E-Mail ignorieren und dein Passwort bleibt unverändert.<br>
|
||||
<br>
|
||||
Um dein Passwort zurückzusetzen, klicke bitte auf den folgenden Link (dieser ist 30 Minuten gültig):<br>
|
||||
<a href='{resetLink}'>{resetLink}</a><br>
|
||||
<br>
|
||||
Viele Grüße<br>Dein Team {_appSettings.Terms.Title}
|
||||
""";
|
||||
|
||||
await _mailService.SendEmailAsync(user.Mail, "Passwort zurücksetzen", mailBody);
|
||||
}
|
||||
|
||||
@@ -71,12 +71,6 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool _dataInitialized;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override OnInitializedAsync
|
||||
|
||||
/// <summary>
|
||||
@@ -85,26 +79,8 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await AuthService.Initialize();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override SetParametersAsync
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
parameters.SetParameterProperties(this);
|
||||
|
||||
if (!_dataInitialized)
|
||||
{
|
||||
_dataInitialized = true;
|
||||
await InitializeDataAsync();
|
||||
}
|
||||
|
||||
// Da die Parameter bereits gesetzt wurden, kann die Basisklasse am Ende aufgerufen werden.
|
||||
await base.SetParametersAsync(ParameterView.Empty);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -5,52 +5,63 @@
|
||||
@inherits FsBase
|
||||
|
||||
@{
|
||||
var colorClass = "";
|
||||
if(Done) colorClass = "interaction--color-done";
|
||||
|
||||
var rowClass = "";
|
||||
if (Done) rowClass += " done";
|
||||
if (NotNeeded) rowClass += " notneeded";
|
||||
if (Alert) rowClass += " fs-alert";
|
||||
}
|
||||
|
||||
<tr class="@rowClass" style="border-top: 5px solid transparent;">
|
||||
<th class="text-center align-top pr-2">
|
||||
<i class="@IconClass"></i>
|
||||
</th>
|
||||
<th class="pr-2 align-top" style="white-space: nowrap;">@Type.Translate(AppSettings):</th>
|
||||
<td class="align-top d-flex flex-column">
|
||||
@if (Interactions.Count > 0)
|
||||
@if(!AllowInteraction || Prospect is {Complete: true })
|
||||
{
|
||||
<Button Size="Size.Small" Disabled="true">
|
||||
<i class="@ButtonIconClass"></i>
|
||||
</Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if(Interactions.Count == 0 || Multiple)
|
||||
{
|
||||
foreach (var interaction in Interactions)
|
||||
{
|
||||
<div style="padding-bottom: .5rem;">
|
||||
<div style="white-space: nowrap;">
|
||||
<span title="@interaction.User.Memo">@interaction.User.Name</span> (@interaction.Date.ToShortDateString())
|
||||
if (Multiple) ButtonIconClass = "fa-solid fa-plus";
|
||||
<Button Size="Size.Small" Clicked="@(async () => { if (AddClick != null) await AddClick(Type); })"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
|
||||
} else {
|
||||
<Button Size="Size.Small" Clicked="@(async () => { await RemoveFirstAsync(Type); })"><i class="fa-solid fa-times" style="color: rgb(153, 0, 0);"></i></Button>
|
||||
}
|
||||
}
|
||||
|
||||
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||
<div class="@colorClass" style="display: inline-block;"><i class="@IconClass"></i> @Type.Translate(AppSettings)</div>
|
||||
|
||||
@if(Interactions.Count > 0)
|
||||
{
|
||||
<span title="@Interactions.First().User.Memo"> (@Interactions.First().User.Name</span> <span>@Interactions.First().Date.ToShortDateString())</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if(Multiple && Interactions.Count > 0)
|
||||
{
|
||||
|
||||
@foreach (var interaction in Interactions)
|
||||
{
|
||||
<div class="d-flex justify-content-end">
|
||||
@if ((Prospect is not { Complete: true } || interaction.Type == InteractionType.Complete) && AllowInteraction)
|
||||
{
|
||||
<span> <a href=""><i class="fa-solid fa-square-xmark" @onclick="async () => { if (RemoveClick != null) await RemoveClick.Invoke(interaction.Id); }" @onclick:preventDefault></i></a></span>
|
||||
<a style="display: inline-block;"" href=""><i class="fa-solid fa-square-xmark" @onclick="async () => { if (RemoveClick != null) await RemoveClick.Invoke(interaction.Id); }" @onclick:preventDefault></i></a>
|
||||
} else {
|
||||
<span>•</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@FeedbackBuilder(interaction)
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span title="@interaction.User.Memo">@interaction.User.Name (@interaction.Date.ToShortDateString())</span>
|
||||
@if (!string.IsNullOrWhiteSpace(interaction.FeedbackInfo))
|
||||
{
|
||||
<span>(<i>@interaction.FeedbackInfo</i>)</span>
|
||||
}
|
||||
</div>
|
||||
@FeedbackBuilder(interaction)
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowInteraction)
|
||||
{
|
||||
if (Multiple) ButtonIconClass = "fa-solid fa-plus";
|
||||
<div class="m-auto">
|
||||
<Button Size="Size.Small" Clicked="@(async () => { if (AddClick != null) await AddClick(Type); })"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -94,6 +94,15 @@ namespace FoodsharingSiegen.Server.Controls
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task RemoveFirstAsync(InteractionType type)
|
||||
{
|
||||
if (Prospect != null && RemoveClick != null)
|
||||
{
|
||||
var interaction = Interactions.FirstOrDefault(x => x.Type == type);
|
||||
if (interaction != null) await RemoveClick(interaction.Id);
|
||||
}
|
||||
}
|
||||
|
||||
private MarkupString FeedbackBuilder(Interaction interaction)
|
||||
{
|
||||
var infoList = new List<string>();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
@using System.ComponentModel
|
||||
@inherits FsBase
|
||||
|
||||
@{
|
||||
var divClass = $"{CssClass} pc-main";
|
||||
var divClass = $"{CssClass} pc-main shadow border-0";
|
||||
if (Prospect is { Complete: true }) divClass += " complete";
|
||||
if (Prospect is { Warning: true }) divClass += " warning";
|
||||
if (Prospect is { RecordState: RecordState.Archived }) divClass += " deleted";
|
||||
@@ -11,7 +12,8 @@
|
||||
|
||||
<div class="@divClass">
|
||||
<h5 class="mb-2 d-flex">
|
||||
<div class="flex-grow-1">
|
||||
<div class="flex-grow-1 d-flex">
|
||||
<div>
|
||||
@if(string.IsNullOrWhiteSpace(Prospect?.Name))
|
||||
{
|
||||
<i class="fa-solid fa-exclamation-triangle text-warning"></i>
|
||||
@@ -23,32 +25,20 @@
|
||||
{
|
||||
@Prospect?.Name
|
||||
}
|
||||
</div>
|
||||
|
||||
<div style="flex-grow: 1;"></div>
|
||||
|
||||
@if (Prospect?.FsId != null && Prospect.FsId != 0)
|
||||
{
|
||||
<small style="font-size: .9rem; margin-left: 0.5rem;">@Prospect?.FsId</small>
|
||||
<a href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank">
|
||||
<small style="font-size: .9rem;">
|
||||
<i class="fa-solid fa-eye"></i> @Prospect?.FsId
|
||||
</small>
|
||||
</a>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div>
|
||||
@if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
|
||||
{
|
||||
<i class="fa-solid fa-pen-to-square link mr-2" @onclick="EditProspectAsync" @onclick:preventDefault></i>
|
||||
}
|
||||
<a href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank"><i class="fa-solid fa-eye"></i></a>
|
||||
@if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
|
||||
{
|
||||
if (Prospect?.RecordState != RecordState.Archived)
|
||||
{
|
||||
<i class="fa-solid fa-box-archive link ml-2" @onclick="ArchiveProspectAsync" title="Archivieren" @onclick:preventDefault></i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-recycle link ml-2" @onclick="RestoreProspectAsync" title="Wiederherstellen" @onclick:preventDefault></i>
|
||||
}
|
||||
|
||||
}
|
||||
</div>
|
||||
</h5>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(Prospect?.Memo))
|
||||
@@ -61,8 +51,7 @@
|
||||
</Alert>
|
||||
}
|
||||
|
||||
<table class="flex-column" style="width: 100%;">
|
||||
|
||||
<div class="interaction-grid mb-3">
|
||||
<InteractionRow
|
||||
Prospect="Prospect"
|
||||
Type="InteractionType.Welcome"
|
||||
@@ -98,12 +87,6 @@
|
||||
IconClass="fa-solid fa-basket-shopping">
|
||||
</InteractionRow>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<hr style="margin: 10px 0;">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<InteractionRow
|
||||
Prospect="Prospect"
|
||||
Type="InteractionType.ReleasedForVerification"
|
||||
@@ -148,27 +131,91 @@
|
||||
ButtonIconClass="fa-solid fa-check"
|
||||
IconClass="fa-solid fa-user-check">
|
||||
</InteractionRow>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<hr style="margin: 10px 0;">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<InteractionRow
|
||||
Prospect="Prospect"
|
||||
AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)"
|
||||
Type="InteractionType.Complete"
|
||||
AddClick="AddInteraction"
|
||||
RemoveClick="@RemoveInteraction"
|
||||
ButtonIconClass="fa-solid fa-check"
|
||||
IconClass="fa-solid fa-flag-checkered">
|
||||
</InteractionRow>
|
||||
}
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1"></div>
|
||||
|
||||
<small class="text-center" style="margin-top: .5rem;">Zuletzt geändert: @Prospect?.Modified?.ToLocalTime()</small>
|
||||
@if(Prospect?.Images?.Count > 0)
|
||||
{
|
||||
<div class="text-center mt-3">
|
||||
<Badge Color="Color.Info" Style="margin-bottom: 0.5rem; cursor: pointer;" @onclick="OpenVerificationDialogAsync"><i class="fa-solid fa-address-card"></i>-Prüfung möglich</Badge></div>
|
||||
}
|
||||
|
||||
<div class="text-center d-flex justify-content-center gap-2 mt-1">
|
||||
|
||||
<Button
|
||||
Color="Color.Secondary"
|
||||
Height="Height.Px(35)"
|
||||
title="Bearbeiten"
|
||||
Clicked="EditProspectAsync"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-pen-to-square"></i>
|
||||
</Button>
|
||||
|
||||
|
||||
@if(StateFilter > ProspectStateFilter.OnBoarding && CurrentUser.IsInGroup(UserGroup.Ambassador))
|
||||
{
|
||||
@if(Prospect?.Complete != true)
|
||||
{
|
||||
<Button
|
||||
Color="Color.Primary"
|
||||
Height="Height.Px(35)"
|
||||
title="Fertigstellen"
|
||||
Clicked="@(() => AddInteraction(InteractionType.Complete))"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-flag-checkered"></i>
|
||||
</Button>
|
||||
} else {
|
||||
<Button
|
||||
Color="Color.Primary"
|
||||
Height="Height.Px(35)"
|
||||
title="Fertigstellen rückgängig"
|
||||
Clicked="@(() => AddInteraction(InteractionType.Complete))"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
|
||||
>
|
||||
<span class="fa-stack" style="vertical-align: top;">
|
||||
<i class="fa-solid fa-slash fa-xl"></i>
|
||||
<i class="fa-solid fa-flag fa-stack-1x"></i>
|
||||
</span>
|
||||
</Button>
|
||||
}
|
||||
}
|
||||
|
||||
<Button
|
||||
Color="Color.Info"
|
||||
Height="Height.Px(35)"
|
||||
title="Identitätsprüfung"
|
||||
Clicked="OpenVerificationDialogAsync"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-address-card"></i>
|
||||
</Button>
|
||||
|
||||
@if (Prospect?.RecordState != RecordState.Archived)
|
||||
{
|
||||
<Button
|
||||
Color="Color.Danger"
|
||||
Height="Height.Px(35)"
|
||||
title="Archivieren"
|
||||
Clicked="ArchiveProspectAsync"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-box-archive"></i>
|
||||
</Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button
|
||||
Color="Color.Success"
|
||||
Height="Height.Px(35)"
|
||||
title="Wiederherstellen"
|
||||
Clicked="RestoreProspectAsync"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-recycle"></i>
|
||||
</Button>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<small class="text-center" style="margin-top: .5rem;">Geändert: @Prospect?.Modified?.ToLocalTime()</small>
|
||||
</div>
|
||||
@@ -43,7 +43,20 @@ namespace FoodsharingSiegen.Server.Controls
|
||||
{
|
||||
var headerText = $"{type.Translate(AppSettings)} für {Prospect.Name} eintragen";
|
||||
|
||||
await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, OnDataChanged));
|
||||
Func<Task> onSuccess = async () =>
|
||||
{
|
||||
if (type == InteractionType.IdCheck && Prospect.Images != null && Prospect.Images.Count > 0)
|
||||
{
|
||||
await ConfirmDialog.ShowAsync(ModalService, "Personalausweisbilder löschen?", $"Möchtest du die Personalausweisbilder von {Prospect.Name} löschen? Diese werden für die weitere Bearbeitung nicht mehr benötigt und enthalten persönliche Daten.", async () =>
|
||||
{
|
||||
var result = await ProspectService.DeleteVerificationImagesAsync(Prospect.Id);
|
||||
await OnDataChanged();
|
||||
});
|
||||
}
|
||||
await OnDataChanged();
|
||||
};
|
||||
|
||||
await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, onSuccess));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +100,16 @@ namespace FoodsharingSiegen.Server.Controls
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OpenVerificationDialogAsync
|
||||
|
||||
private async Task OpenVerificationDialogAsync()
|
||||
{
|
||||
if (Prospect == null) return;
|
||||
await VerificationSettingsDialog.ShowAsync(ModalService, Prospect, OnDataChanged);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method RemoveInteraction
|
||||
|
||||
/// <summary>
|
||||
@@ -106,6 +129,27 @@ namespace FoodsharingSiegen.Server.Controls
|
||||
});
|
||||
}
|
||||
|
||||
private async Task RemoveInteraction(InteractionType type)
|
||||
{
|
||||
var typeName = type.Translate(AppSettings);
|
||||
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Alle {typeName}-Interaktionen wirklich entfernen?", async () =>
|
||||
{
|
||||
var interactions = Prospect?.Interactions.Where(x => x.Type == type);
|
||||
|
||||
var dataChanged = false;
|
||||
|
||||
foreach (var interaction in interactions ?? [])
|
||||
{
|
||||
var removeR = await ProspectService.RemoveInteraction(interaction.Id);
|
||||
if (!removeR.Success) continue;
|
||||
|
||||
dataChanged = true;
|
||||
}
|
||||
|
||||
if(dataChanged && OnDataChanged != null) await OnDataChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method RestoreProspectAsync
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
::deep a,
|
||||
::deep a.invert:hover{
|
||||
|
||||
color: #64ae24;
|
||||
}
|
||||
|
||||
::deep a.invert,
|
||||
::deep a:hover {
|
||||
color: #533a20;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: #64ae24;
|
||||
}
|
||||
|
||||
.pc-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
max-width: 480px;
|
||||
border: 1px solid #533a20;
|
||||
border-radius: 3px;
|
||||
margin: 5px;
|
||||
padding: .5rem .5rem 0 .5rem;
|
||||
}
|
||||
|
||||
.pc-main.warning {
|
||||
-webkit-box-shadow: 0 0 9px 4px rgba(214,100,23,0.87);
|
||||
-moz-box-shadow: 0 0 9px 4px rgba(214,100,23,0.87);
|
||||
box-shadow: 0 0 9px 4px rgba(214,100,23,0.87);
|
||||
}
|
||||
|
||||
.pc-main.deleted {
|
||||
-webkit-box-shadow: 0 0 9px 4px rgb(214 23 23 / 87%);
|
||||
-moz-box-shadow: 0 0 9px 4px rgb(214 23 23 / 87%);
|
||||
box-shadow: 0 0 9px 4px rgb(214 23 23 / 87%);
|
||||
}
|
||||
|
||||
.complete {
|
||||
background: #76ff003b;
|
||||
}
|
||||
|
||||
i.link {
|
||||
cursor: pointer; color: #64ae24;
|
||||
}
|
||||
|
||||
i.link:hover {
|
||||
color: #000;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
::deep a {
|
||||
color: #64ae24;
|
||||
display: block;
|
||||
|
||||
&.invert,
|
||||
&:hover {
|
||||
color: #533a20;
|
||||
}
|
||||
|
||||
&.invert:hover {
|
||||
color: #64ae24;
|
||||
}
|
||||
}
|
||||
|
||||
.green {
|
||||
color: #64ae24;
|
||||
}
|
||||
|
||||
.pc-main {
|
||||
background-color: #FFF;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
border-radius: 12px;
|
||||
margin: 0;
|
||||
padding: 1rem 1rem 0 1rem;
|
||||
|
||||
@media (max-width: 576px) {
|
||||
padding: .5rem .5rem 0 .5rem;
|
||||
}
|
||||
|
||||
&.warning {
|
||||
box-shadow: rgb(255 145 0 / 36%) 0px 8px 10px 1px, rgb(255 145 0 / 44%) 0px 3px 14px 2px, rgb(255 145 0 / 49%) 0px 5px 5px -3px !important;
|
||||
}
|
||||
|
||||
&.deleted {
|
||||
box-shadow: rgba(255, 0, 0, 0.36) 0px 8px 10px 1px, rgba(255, 0, 0, 0.44) 0px 3px 14px 2px, rgba(255, 0, 0, 0.49) 0px 5px 5px -3px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.complete {
|
||||
background: #76ff003b;
|
||||
}
|
||||
|
||||
i.link {
|
||||
cursor: pointer;
|
||||
color: #64ae24;
|
||||
|
||||
&:hover {
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
.interaction-grid {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
align-items: center;
|
||||
gap: .5rem;
|
||||
|
||||
::deep .interaction {
|
||||
&--color {
|
||||
&-done{
|
||||
color: #64ae24;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
@using FoodsharingSiegen.Contracts.Model
|
||||
@inherits FsBase
|
||||
@code {
|
||||
|
||||
[Parameter] public ProspectFilter Filter { get; set; } = new();
|
||||
|
||||
[Parameter] public EventCallback<ProspectFilter> FilterChanged { get; set; }
|
||||
|
||||
[Parameter] public ProspectStateFilter StateFilter { get; set; }
|
||||
|
||||
|
||||
private async Task WithoutStepInBriefingChangedAsync(bool arg)
|
||||
{
|
||||
Filter.WithoutStepInBriefing = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task TextChanged(string arg)
|
||||
{
|
||||
Filter.Text = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task WithoutIdCheckChangedAsync(bool arg)
|
||||
{
|
||||
Filter.WithoutIdCheck = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task NoActivityChangedAsync(bool arg)
|
||||
{
|
||||
Filter.NoActivity = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task DeletedOnlyChangedAsync(bool arg)
|
||||
{
|
||||
Filter.DeletedOnly = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task RecentActivityChangedAsync(bool arg)
|
||||
{
|
||||
Filter.RecentActivity = arg;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header" style="padding: .5rem;">
|
||||
<i class="fa-solid fa-filter"></i> Suchfilter
|
||||
</div>
|
||||
<div class="card-body" style="padding: .5rem;">
|
||||
|
||||
@if (!AppSettings.DisableStepIn)
|
||||
{
|
||||
@* WITHOUT STEP IN BRIEFING *@
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.WithoutStepInBriefing" CheckedChanged="WithoutStepInBriefingChangedAsync" Color="Color.Primary">Ohne @AppSettings.Terms.StepInName</Switch>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@* WITHOUT ID CHECK *@
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.Verification, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.WithoutIdCheck" CheckedChanged="WithoutIdCheckChangedAsync" Color="Color.Primary">Perso noch nicht geprüft</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* RECENT ACTIVITY *@
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.RecentActivity" CheckedChanged="RecentActivityChangedAsync" Color="Color.Primary">Kürzlich geändert (< 6 Monate)</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* NO ACTIVITY *@
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.NoActivity" CheckedChanged="NoActivityChangedAsync" Color="Color.Primary">Lange keine Aktivität (> 6 Monate)</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* DELETED ONLY *@
|
||||
@if (new[] { ProspectStateFilter.All }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="Filter.DeletedOnly" CheckedChanged="DeletedOnlyChangedAsync" Color="Color.Primary">Gelöschte</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
<TextEdit Text="@Filter.Text" TextChanged="TextChanged" Placeholder="Suchen..." Debounce="true" DebounceInterval="200"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -7,12 +7,14 @@
|
||||
|
||||
[Parameter] public Func<Task>? OnDataChanged { get; set; }
|
||||
|
||||
[Parameter] public string GridClass { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
<h5>@(Prospects?.Count ?? 0) Einträge</h5>
|
||||
<h6>@(Prospects?.Count ?? 0) Ergebnisse</h6>
|
||||
|
||||
@if (Prospects?.Any() == true)
|
||||
{
|
||||
<div class="row m-0">
|
||||
<div class="prospect-grid @GridClass">
|
||||
<Repeater Items="@Prospects">
|
||||
<ProspectContainer
|
||||
Prospect="context"
|
||||
|
||||
8
FoodsharingSiegen.Server/Controls/ProspectGrid.razor.css
Normal file
@@ -0,0 +1,8 @@
|
||||
.prospect-grid {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
justify-content: center;
|
||||
align-items: stretch;
|
||||
}
|
||||
@@ -1,17 +1,56 @@
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
|
||||
|
||||
<Button Color="Color.Primary"
|
||||
<Button Color="Color.Primary"
|
||||
Width="Width.Px(50)"
|
||||
Height="Height.Px(50)"
|
||||
title="Sortieren"
|
||||
style="min-width: auto;"
|
||||
Clicked="@OpenSortDialogAsync">
|
||||
<i class="fa-solid fa-sort"></i>
|
||||
</Button>
|
||||
</Button>
|
||||
|
||||
<div class="badge-row mt-2">
|
||||
<Button Color="Color.Info"
|
||||
Width="Width.Px(50)"
|
||||
Height="Height.Px(50)"
|
||||
title="Filtern"
|
||||
style="min-width: auto;"
|
||||
Clicked="@OpenFilterDialogAsync">
|
||||
<i class="fa-solid fa-filter"></i>
|
||||
</Button>
|
||||
|
||||
<div style="flex-grow: 1;" class="mt-3">
|
||||
<TextEdit Text="@Filter.Text" TextChanged="TextChangedAsync" Placeholder="Suchen..." Debounce="true" DebounceInterval="200" Style="border: 1px solid #64ae24; background: #fff;" Class="pl-2" />
|
||||
</div>
|
||||
|
||||
<div class="badge-row mt-1 mb-3">
|
||||
@if (HasCustomSort)
|
||||
{
|
||||
<Badge Color="Color.Primary" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, ResetSortAsync)">@CurrentSortText</Badge>
|
||||
<Badge class="mr-1" Color="Color.Primary" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, ResetSortAsync)">@CurrentSortText</Badge>
|
||||
}
|
||||
|
||||
@if (Filter.WithoutStepInBriefing)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.WithoutStepInBriefing)))">Ohne @AppSettings.Terms.StepInName</Badge>
|
||||
}
|
||||
@if (Filter.WithoutIdCheck)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.WithoutIdCheck)))">Perso noch nicht geprüft</Badge>
|
||||
}
|
||||
@if (Filter.RecentActivity)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.RecentActivity)))">Kürzlich geändert</Badge>
|
||||
}
|
||||
@if (Filter.NoActivity)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.NoActivity)))">Lange keine Aktivität</Badge>
|
||||
}
|
||||
@if (Filter.DeletedOnly)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.DeletedOnly)))">Gelöschte</Badge>
|
||||
}
|
||||
@if(Filter.IdCheckPossible)
|
||||
{
|
||||
<Badge class="mr-1 mb-1" Color="Color.Info" Closable="true" CloseClicked="@EventCallback.Factory.Create(this, () => DisableFilterAsync(nameof(Filter.IdCheckPossible)))">Perso-Prüfung möglich</Badge>
|
||||
}
|
||||
</div>
|
||||
@@ -1,6 +1,7 @@
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Enums;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Dialogs;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
@@ -10,10 +11,6 @@ namespace FoodsharingSiegen.Server.Controls;
|
||||
|
||||
public partial class ProspectSortControl
|
||||
{
|
||||
[Inject] private IModalService ModalService { get; set; } = null!;
|
||||
|
||||
[Inject] private LocalStorageService LocalStorageService { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
|
||||
|
||||
@@ -26,6 +23,10 @@ public partial class ProspectSortControl
|
||||
[Parameter]
|
||||
public string? StorageKey { get; set; }
|
||||
|
||||
[Parameter] public ProspectFilter Filter { get; set; } = new();
|
||||
[Parameter] public EventCallback<ProspectFilter> FilterChanged { get; set; }
|
||||
[Parameter] public ProspectStateFilter StateFilter { get; set; } = ProspectStateFilter.All;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(StorageKey))
|
||||
@@ -48,6 +49,36 @@ public partial class ProspectSortControl
|
||||
});
|
||||
}
|
||||
|
||||
private async Task OpenFilterDialogAsync()
|
||||
{
|
||||
await ProspectFilterDialog.ShowAsync(ModalService, Filter, StateFilter, async (f) =>
|
||||
{
|
||||
Filter = f;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task TextChangedAsync(string text)
|
||||
{
|
||||
Filter.Text = text;
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private async Task DisableFilterAsync(string filterPropName)
|
||||
{
|
||||
switch (filterPropName)
|
||||
{
|
||||
case nameof(Filter.WithoutStepInBriefing): Filter.WithoutStepInBriefing = false; break;
|
||||
case nameof(Filter.WithoutIdCheck): Filter.WithoutIdCheck = false; break;
|
||||
case nameof(Filter.RecentActivity): Filter.RecentActivity = false; break;
|
||||
case nameof(Filter.NoActivity): Filter.NoActivity = false; break;
|
||||
case nameof(Filter.DeletedOnly): Filter.DeletedOnly = false; break;
|
||||
case nameof(Filter.IdCheckPossible): Filter.IdCheckPossible = false; break;
|
||||
}
|
||||
await FilterChanged.InvokeAsync(Filter);
|
||||
}
|
||||
|
||||
private bool HasCustomSort => CurrentSort != ProspectSortOption.NameAscending;
|
||||
|
||||
private string CurrentSortText => CurrentSort switch
|
||||
|
||||
@@ -37,6 +37,16 @@ namespace FoodsharingSiegen.Server.Data
|
||||
return $"hat dem Neuling {audit.Data1} folgendes hinzugefügt: {audit.Data2}";
|
||||
case AuditType.RemoveInteraction:
|
||||
return $"hat eine Interaktion bei {audit.Data1} gelöscht.";
|
||||
case AuditType.DeleteProspectImages:
|
||||
return $"hat die Bilder von {audit.Data1} gelöscht.";
|
||||
case AuditType.ViewProspectImages:
|
||||
return $"hat die Bilder von {audit.Data1} angesehen.";
|
||||
case AuditType.UploadProspectImage:
|
||||
return $"hat ein Bild für {audit.Data1} hochgeladen.";
|
||||
case AuditType.RequestPasswordReset:
|
||||
return $"hat ein Passwort-Reset für {audit.Data1} angefordert.";
|
||||
case AuditType.ChangeOwnPassword:
|
||||
return $"hat das eigene Passwort geändert.";
|
||||
case AuditType.None:
|
||||
default:
|
||||
return $"{audit.Data1}, {audit.Data2}";
|
||||
|
||||
@@ -27,6 +27,11 @@ namespace FoodsharingSiegen.Server.Data
|
||||
/// </summary>
|
||||
public DbSet<Prospect>? Prospects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the uploaded verification images mapping.
|
||||
/// </summary>
|
||||
public DbSet<ProspectImage>? ProspectImages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the users (ab)
|
||||
/// </summary>
|
||||
@@ -41,9 +46,12 @@ namespace FoodsharingSiegen.Server.Data
|
||||
/// </summary>
|
||||
/// <param name="options">The options (ab)</param>
|
||||
public FsContext(DbContextOptions<FsContext> options) : base(options)
|
||||
{
|
||||
if (Database.IsRelational())
|
||||
{
|
||||
Database.Migrate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
Data2 = data2
|
||||
};
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(DateTime.Now.ToString() + " " + CurrentUser?.Name + " " + AuditHelper.CreateText(audit));
|
||||
Console.WriteLine();
|
||||
|
||||
Context.Audits?.Add(audit);
|
||||
var saveR = await Context.SaveChangesAsync();
|
||||
|
||||
@@ -61,29 +65,56 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Method Load
|
||||
#region Public Method GetCount
|
||||
|
||||
/// <summary>
|
||||
/// Loads the count (a. beging, 23.05.2022)
|
||||
/// Gets the total count (ab)
|
||||
/// </summary>
|
||||
/// <param name="count">The count</param>
|
||||
/// <param name="type">The type</param>
|
||||
/// <returns>A task containing an operation result of list audit</returns>
|
||||
public async Task<OperationResult<List<Audit>>> Load(int count, AuditType? type = null)
|
||||
/// <returns>A task containing an operation result of count</returns>
|
||||
public async Task<OperationResult<int>> GetCount(AuditType? type = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
||||
|
||||
if (count > 0)
|
||||
query = query?.Take(count);
|
||||
var query = Context.Audits?.AsQueryable();
|
||||
|
||||
if (type != null)
|
||||
query = query?.Where(x => x.Type == type);
|
||||
|
||||
var mat = query?.ToList();
|
||||
if (query == null) return new(0);
|
||||
|
||||
var count = await query.CountAsync();
|
||||
return new(count);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Method LoadPage
|
||||
|
||||
/// <summary>
|
||||
/// Loads the page of audits (ab)
|
||||
/// </summary>
|
||||
/// <param name="skip">The skip count</param>
|
||||
/// <param name="take">The take count</param>
|
||||
/// <param name="type">The type</param>
|
||||
/// <returns>A task containing an operation result of list audit</returns>
|
||||
public async Task<OperationResult<List<Audit>>> LoadPage(int skip, int take, AuditType? type = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
||||
|
||||
if (type != null)
|
||||
query = query?.Where(x => x.Type == type);
|
||||
|
||||
query = query?.Skip(skip).Take(take);
|
||||
|
||||
var mat = await query!.ToListAsync();
|
||||
|
||||
if (mat != null) return new(mat);
|
||||
|
||||
|
||||
@@ -111,7 +111,10 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospectsQuery = Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).AsQueryable();
|
||||
var prospectsQuery = Context.Prospects!.AsNoTracking()
|
||||
.Include(x => x.Images)
|
||||
.Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User)
|
||||
.OrderBy(x => x.Name).AsQueryable();
|
||||
|
||||
if(parameter.MustHaveInteractions != null && parameter.MustHaveInteractions.Any())
|
||||
prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => parameter.MustHaveInteractions.Contains(i.Type)));
|
||||
@@ -206,5 +209,152 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image Upload Features
|
||||
|
||||
public async Task<OperationResult<Guid>> GenerateVerificationTokenAsync(Guid prospectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospect = await Context.Prospects!
|
||||
.Include(x => x.Interactions)
|
||||
.FirstOrDefaultAsync(x => x.Id == prospectId);
|
||||
|
||||
if (prospect == null) return new(new Exception("Prospect not found"));
|
||||
|
||||
if (prospect.Interactions.Any(x => x.Type == InteractionType.Verify))
|
||||
return new(new Exception("Die Identitätsprüfung wurde bereits abgeschlossen. Es kann kein neuer Token generiert werden."));
|
||||
|
||||
prospect.VerificationToken = Guid.NewGuid();
|
||||
prospect.Modified = DateTime.UtcNow;
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
return new(prospect.VerificationToken.Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OperationResult<Prospect>> GetProspectByVerificationTokenAsync(Guid token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospect = await Context.Prospects!
|
||||
.Include(x => x.Interactions)
|
||||
.Include(x => x.Images)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.VerificationToken == token);
|
||||
|
||||
if (prospect == null) return new(new Exception("Ungültiger oder abgelaufener Token."));
|
||||
|
||||
if (prospect.Interactions.Any(x => x.Type == InteractionType.Verify))
|
||||
return new(new Exception("Die Identitätsprüfung wurde bereits abgeschlossen. Ein Hochladen weiterer Bilder ist nicht mehr möglich."));
|
||||
|
||||
return new(prospect);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OperationResult> AddVerificationImageAsync(Guid prospectId, byte[] imageData, string contentType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospect = await Context.Prospects!
|
||||
.Include(x => x.Interactions)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.Id == prospectId);
|
||||
|
||||
if (prospect == null) return new(new Exception("Foodsaver nicht gefunden."));
|
||||
|
||||
if (prospect.Interactions.Any(x => x.Type == InteractionType.Verify))
|
||||
return new(new Exception("Die Identitätsprüfung wurde bereits abgeschlossen. Ein Hochladen weiterer Bilder ist nicht mehr möglich."));
|
||||
|
||||
// Verify max 5 images
|
||||
var imgCount = await Context.ProspectImages!.CountAsync(x => x.ProspectId == prospectId);
|
||||
if (imgCount >= 5) return new(new Exception("Maximum 5 images allowed"));
|
||||
|
||||
var image = new ProspectImage
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
ProspectId = prospectId,
|
||||
ImageData = imageData,
|
||||
ContentType = contentType,
|
||||
Created = DateTime.UtcNow
|
||||
};
|
||||
|
||||
await Context.ProspectImages!.AddAsync(image);
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
await AuditService.Insert(AuditType.UploadProspectImage, prospect.Name);
|
||||
|
||||
return new();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<ProspectImage>>> GetVerificationImagesAsync(Guid prospectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var images = await Context.ProspectImages!
|
||||
.AsNoTracking()
|
||||
.Where(x => x.ProspectId == prospectId)
|
||||
.OrderBy(x => x.Created)
|
||||
.ToListAsync();
|
||||
|
||||
var prospectName = await Context.Prospects!
|
||||
.Where(x => x.Id == prospectId)
|
||||
.Select(x => x.Name)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(prospectName))
|
||||
{
|
||||
await AuditService.Insert(AuditType.ViewProspectImages, prospectName);
|
||||
}
|
||||
|
||||
return new(images);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OperationResult> DeleteVerificationImagesAsync(Guid prospectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var images = await Context.ProspectImages!.Where(x => x.ProspectId == prospectId).ToListAsync();
|
||||
if (images.Any())
|
||||
{
|
||||
Context.ProspectImages!.RemoveRange(images);
|
||||
|
||||
var prospect = await Context.Prospects!.FirstOrDefaultAsync(x => x.Id == prospectId);
|
||||
if (prospect != null)
|
||||
{
|
||||
prospect.VerificationToken = null; // Clear token when images are deleted
|
||||
await AuditService.Insert(AuditType.DeleteProspectImages, prospect.Name);
|
||||
}
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new(e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,13 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
var user = await Context.Users!.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == userId);
|
||||
if (user == null) return new(new Exception("User not found"));
|
||||
|
||||
if (user.Type == UserType.Admin)
|
||||
{
|
||||
var adminCount = await Context.Users!.CountAsync(x => x.Type == UserType.Admin && x.Id != userId);
|
||||
if (adminCount == 0)
|
||||
return new(new Exception("Der letzte Administrator kann nicht gelöscht werden."));
|
||||
}
|
||||
|
||||
// Interaktionen vom aktuellen Nutzer übernehmen
|
||||
if(CurrentUser?.Id != null)
|
||||
foreach (var userInteraction in user.Interactions)
|
||||
@@ -151,8 +158,14 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
|
||||
if (saveR < 1) return new(new Exception("Fehler beim Speichern"));
|
||||
|
||||
var auditData = CurrentUser?.Id == user.Id ? "sich selbst" : user.Mail;
|
||||
await AuditService.Insert(AuditType.SetUserPassword, auditData);
|
||||
if (CurrentUser?.Id == user.Id)
|
||||
{
|
||||
await AuditService.Insert(AuditType.ChangeOwnPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
await AuditService.Insert(AuditType.SetUserPassword, user.Mail);
|
||||
}
|
||||
|
||||
return new();
|
||||
}
|
||||
@@ -178,8 +191,14 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id);
|
||||
if (entityUser == null) return new(new Exception("User not found"));
|
||||
|
||||
if (entityUser.Type == UserType.Admin && user.Type != UserType.Admin)
|
||||
{
|
||||
var adminCount = await Context.Users!.CountAsync(x => x.Type == UserType.Admin && x.Id != user.Id);
|
||||
if (adminCount == 0)
|
||||
return new(new Exception("Der Typ des letzten Administrators kann nicht geändert werden."));
|
||||
}
|
||||
|
||||
if (entityUser.Mail != user.Mail ||
|
||||
entityUser.Verified != user.Verified ||
|
||||
entityUser.Type != user.Type ||
|
||||
entityUser.Groups != user.Groups)
|
||||
entityUser.ForceLogout = true;
|
||||
@@ -188,7 +207,6 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
entityUser.Mail = user.Mail;
|
||||
entityUser.Name = user.Name;
|
||||
entityUser.Type = user.Type;
|
||||
entityUser.Verified = user.Verified;
|
||||
entityUser.Groups = user.Groups;
|
||||
entityUser.Network = user.Network;
|
||||
|
||||
|
||||
@@ -127,9 +127,10 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
Interaction.UserID = CurrentUser.Id;
|
||||
|
||||
var addR = await ProspectService.AddInteraction(Interaction);
|
||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
|
||||
await ModalService.Hide();
|
||||
|
||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
58
FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor
Normal file
@@ -0,0 +1,58 @@
|
||||
@inherits FsBase
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
@if (!AppSettings.DisableStepIn && new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.WithoutStepInBriefing" CheckedChanged="(v) => { ModalFilter.WithoutStepInBriefing = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Ohne @AppSettings.Terms.StepInName
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.Verification, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.WithoutIdCheck" CheckedChanged="(v) => { ModalFilter.WithoutIdCheck = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Perso noch nicht geprüft
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if(new[] { ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.IdCheckPossible" CheckedChanged="(v) => { ModalFilter.IdCheckPossible = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Perso-Prüfung möglich
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.RecentActivity" CheckedChanged="(v) => { ModalFilter.RecentActivity = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Kürzlich geändert (< 6 Monate)
|
||||
</Switch>
|
||||
</div>
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.NoActivity" CheckedChanged="(v) => { ModalFilter.NoActivity = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Lange keine Aktivität (> 6 Monate)
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (StateFilter == ProspectStateFilter.All)
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.DeletedOnly" CheckedChanged="(v) => { ModalFilter.DeletedOnly = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Gelöschte
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<Button Color="Color.Primary" Clicked="ApplyAsync" Block="true">Anwenden</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,52 @@
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Enums;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.BaseClasses;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Dialogs
|
||||
{
|
||||
public partial class ProspectFilterDialog : FsBase
|
||||
{
|
||||
[Parameter] public ProspectFilter CurrentFilter { get; set; } = new();
|
||||
[Parameter] public ProspectStateFilter StateFilter { get; set; } = ProspectStateFilter.All;
|
||||
[Parameter] public Func<ProspectFilter, Task>? OnFilterApplied { get; set; }
|
||||
|
||||
public ProspectFilter ModalFilter { get; set; } = new();
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// Clone the filter so changes are not immediately mapped to the parent until "Anwenden" is pressed
|
||||
ModalFilter = new ProspectFilter
|
||||
{
|
||||
Text = CurrentFilter.Text,
|
||||
WithoutStepInBriefing = CurrentFilter.WithoutStepInBriefing,
|
||||
WithoutIdCheck = CurrentFilter.WithoutIdCheck,
|
||||
NoActivity = CurrentFilter.NoActivity,
|
||||
RecentActivity = CurrentFilter.RecentActivity,
|
||||
DeletedOnly = CurrentFilter.DeletedOnly,
|
||||
IdCheckPossible = CurrentFilter.IdCheckPossible
|
||||
};
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
public static async Task ShowAsync(IModalService modalService, ProspectFilter currentFilter, ProspectStateFilter stateFilter, Func<ProspectFilter, Task> onFilterApplied)
|
||||
{
|
||||
await modalService.Show<ProspectFilterDialog>("Filtern", p =>
|
||||
{
|
||||
p.Add(nameof(CurrentFilter), currentFilter);
|
||||
p.Add(nameof(StateFilter), stateFilter);
|
||||
p.Add(nameof(OnFilterApplied), onFilterApplied);
|
||||
}, new ModalInstanceOptions
|
||||
{
|
||||
Size = ModalSize.Small,
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ApplyAsync()
|
||||
{
|
||||
if (OnFilterApplied != null) await OnFilterApplied(ModalFilter);
|
||||
await ModalService.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
@using Blazorise
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
@inherits FsBase
|
||||
|
||||
<div class="mt-1 mb-3">
|
||||
<div class="d-grid gap-3">
|
||||
|
||||
@if (ShowLinkPanel)
|
||||
{
|
||||
<div class="border p-3 rounded">
|
||||
<p class="mb-2 text-muted">Kopiere diesen Link und teile ihn mit <strong>@Prospect?.Name</strong>:</p>
|
||||
<div>
|
||||
<input type="text" class="form-control" value="@LinkUrl" readonly />
|
||||
@if(CopySuccess)
|
||||
{
|
||||
<div class="alert alert-success py-2 mt-2 mb-0">Link wurde in die Zwischenablage kopiert!</div>
|
||||
}
|
||||
<Button Color="Color.Secondary" Clicked="CopyLink" Style="width: 100%;" Class="mt-2">
|
||||
<i class="fa-solid fa-copy mr-2"></i>Link kopieren
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button Color="Color.Info" Clicked="@GenerateLinkAsync">
|
||||
<i class="fa-solid fa-link me-2"></i> Upload-Link erstellen / anzeigen
|
||||
</Button>
|
||||
|
||||
@if(CurrentUser.IsAdmin() || CurrentUser.IsInGroup(UserGroup.Ambassador))
|
||||
{
|
||||
<Button Color="Color.Success" Clicked="@ViewImagesAsync" Disabled="@(ImageCount == 0)">
|
||||
<i class="fa-solid fa-images me-2"></i> Hochgeladene Bilder ansehen (@ImageCount)
|
||||
</Button>
|
||||
}
|
||||
|
||||
|
||||
<Button Color="Color.Danger" Clicked="@DeleteImagesAsync" Disabled="@(ImageCount == 0)">
|
||||
<i class="fa-solid fa-trash-can me-2"></i> Alle Bilder löschen
|
||||
</Button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,110 @@
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.BaseClasses;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Dialogs
|
||||
{
|
||||
public partial class VerificationSettingsDialog : FsBase
|
||||
{
|
||||
[Inject]
|
||||
public ProspectService ProspectService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
public IJSRuntime JS { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public Prospect? Prospect { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Func<Task>? OnDataChanged { get; set; }
|
||||
|
||||
private int ImageCount { get; set; } = 0;
|
||||
private bool ShowLinkPanel { get; set; } = false;
|
||||
|
||||
private bool CopySuccess { get; set; } = false;
|
||||
private string LinkUrl { get; set; } = string.Empty;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (Prospect != null)
|
||||
{
|
||||
var result = await ProspectService.GetVerificationImagesAsync(Prospect.Id);
|
||||
if (result.Success && result.Data != null)
|
||||
{
|
||||
ImageCount = result.Data.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task ShowAsync(IModalService modalService, Prospect? prospect, Func<Task>? onDataChanged)
|
||||
{
|
||||
var title = "Identitätsprüfung";
|
||||
var action = new Action<ModalProviderParameterBuilder<VerificationSettingsDialog>>(b =>
|
||||
{
|
||||
b.Add(nameof(Prospect), prospect);
|
||||
b.Add(nameof(OnDataChanged), onDataChanged);
|
||||
});
|
||||
|
||||
await modalService.Show(title, action, new ModalInstanceOptions { Size = ModalSize.Default });
|
||||
}
|
||||
|
||||
private async Task GenerateLinkAsync()
|
||||
{
|
||||
if (Prospect == null) return;
|
||||
|
||||
Guid token = Prospect.VerificationToken ?? Guid.Empty;
|
||||
|
||||
if (token == Guid.Empty)
|
||||
{
|
||||
var result = await ProspectService.GenerateVerificationTokenAsync(Prospect.Id);
|
||||
if (result.Success)
|
||||
{
|
||||
token = result.Data;
|
||||
if (OnDataChanged != null) await OnDataChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
await Notification.Error(result.Exception?.Message ?? "Ein Fehler ist aufgetreten.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LinkUrl = NavigationManager.BaseUri + "verify/" + token.ToString();
|
||||
ShowLinkPanel = true;
|
||||
}
|
||||
|
||||
private async Task CopyLink()
|
||||
{
|
||||
await JS.InvokeVoidAsync("navigator.clipboard.writeText", LinkUrl);
|
||||
CopySuccess = true;
|
||||
}
|
||||
|
||||
private async Task ViewImagesAsync()
|
||||
{
|
||||
await ModalService.Hide();
|
||||
if (Prospect != null)
|
||||
{
|
||||
await ViewImagesDialog.ShowAsync(ModalService, Prospect);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteImagesAsync()
|
||||
{
|
||||
if (Prospect == null) return;
|
||||
|
||||
await ConfirmDialog.ShowAsync(ModalService, "Bilder Löschen", $"Sollen alle Identitätsprüfungsbilder von {Prospect.Name} unwiderruflich gelöscht werden?", async () =>
|
||||
{
|
||||
var result = await ProspectService.DeleteVerificationImagesAsync(Prospect.Id);
|
||||
if (result.Success)
|
||||
{
|
||||
ImageCount = 0;
|
||||
|
||||
if(OnDataChanged != null) await OnDataChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
48
FoodsharingSiegen.Server/Dialogs/ViewImagesDialog.razor
Normal file
@@ -0,0 +1,48 @@
|
||||
@using Blazorise
|
||||
@inherits FsBase
|
||||
|
||||
@if (SelectedImageIndex.HasValue)
|
||||
{
|
||||
<div class="text-center position-relative">
|
||||
<Button Color="Color.Secondary" Class="position-absolute start-0 top-0 m-2 z-3 text-white bg-dark border-0 rounded-circle w-40px h-40px fs-4 lh-1" Clicked="() => SelectedImageIndex = null">
|
||||
<i class="fa-solid fa-close"></i>
|
||||
</Button>
|
||||
|
||||
<a href="@(_images[SelectedImageIndex.Value])" target="_blank" download>
|
||||
<img src="@(_images[SelectedImageIndex.Value])" class="img-fluid rounded" style="max-height: 80vh;" />
|
||||
</a>
|
||||
|
||||
<div class="d-flex justify-content-between position-absolute top-50 start-0 w-100">
|
||||
<Button Color="Color.Dark" Class="rounded-circle" Disabled="@(SelectedImageIndex.Value == 0)" Clicked="() => SelectedImageIndex--"><i class="fa-solid fa-chevron-left"></i></Button>
|
||||
<Button Color="Color.Dark" Class="rounded-circle" Disabled="@(SelectedImageIndex.Value == _images.Count - 1)" Clicked="() => SelectedImageIndex++"><i class="fa-solid fa-chevron-right"></i></Button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (_isLoading)
|
||||
{
|
||||
<div class="text-center my-3"><div class="spinner-border text-success"></div></div>
|
||||
}
|
||||
else if (_images.Any())
|
||||
{
|
||||
<div class="row row-cols-1 row-cols-md-3 g-2">
|
||||
@for (int i = 0; i < _images.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
<div class="col">
|
||||
<div class="card h-100 shadow-sm" style="cursor:pointer;" @onclick="() => SelectedImageIndex = index">
|
||||
<img src="@(_images[index])" class="card-img-top mh-100 object-fit-cover" style="height: 200px" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info">Keine Bilder vorhanden.</div>
|
||||
}
|
||||
<div class="mt-3 text-end">
|
||||
<Button Color="Color.Secondary" Clicked="@(() => ModalService.Hide())">Schließen</Button>
|
||||
</div>
|
||||
}
|
||||
50
FoodsharingSiegen.Server/Dialogs/ViewImagesDialog.razor.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.BaseClasses;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Dialogs
|
||||
{
|
||||
public partial class ViewImagesDialog : FsBase
|
||||
{
|
||||
[Inject]
|
||||
public ProspectService ProspectService { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public Prospect? Prospect { get; set; }
|
||||
|
||||
private bool _isLoading = true;
|
||||
private List<string> _images = new();
|
||||
private int? SelectedImageIndex { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (Prospect != null)
|
||||
{
|
||||
var result = await ProspectService.GetVerificationImagesAsync(Prospect.Id);
|
||||
if (result.Success && result.Data != null)
|
||||
{
|
||||
foreach (var image in result.Data)
|
||||
{
|
||||
var base64 = Convert.ToBase64String(image.ImageData);
|
||||
var imgSrc = $"data:{image.ContentType};base64,{base64}";
|
||||
_images.Add(imgSrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
_isLoading = false;
|
||||
}
|
||||
|
||||
public static async Task ShowAsync(IModalService modalService, Prospect prospect)
|
||||
{
|
||||
var title = $"Bilder für {prospect.Name}";
|
||||
var action = new Action<ModalProviderParameterBuilder<ViewImagesDialog>>(b =>
|
||||
{
|
||||
b.Add(nameof(Prospect), prospect);
|
||||
});
|
||||
|
||||
await modalService.Show(title, action, new ModalInstanceOptions { Size = ModalSize.ExtraLarge });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,14 +22,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<LibSassOutputStyle>expanded</LibSassOutputStyle>
|
||||
<LibSassOutputLevel>verbose</LibSassOutputLevel>
|
||||
<LibSassMessageLevel>High</LibSassMessageLevel>
|
||||
<DartSassOutputStyle>expanded</DartSassOutputStyle>
|
||||
<DartSassOutputLevel>verbose</DartSassOutputLevel>
|
||||
<DartSassMessageLevel>High</DartSassMessageLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LibSassBuilder" Version="2.0.1" />
|
||||
<PackageReference Include="MailKit" Version="4.4.0" />
|
||||
<PackageReference Include="AspNetCore.SassCompiler" Version="1.81.1" />
|
||||
<PackageReference Include="MailKit" Version="4.16.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(FsContext))]
|
||||
[Migration("20220521155432_init")]
|
||||
partial class init
|
||||
partial class Init
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
public partial class init : Migration
|
||||
public partial class Init : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
267
FoodsharingSiegen.Server/Migrations/20260420122950_AddImageVerification.Designer.cs
generated
Normal file
@@ -0,0 +1,267 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(FsContext))]
|
||||
[Migration("20260420122950_AddImageVerification")]
|
||||
partial class AddImageVerification
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Data1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Data2")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("UserID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Audits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Alert")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Feedback")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FeedbackInfo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Info1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Info2")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("NotNeeded")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("ProspectID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("UserID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProspectID");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Interactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("FsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Memo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("Modified")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("RecordState")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("VerificationToken")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Warning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Prospects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<byte[]>("ImageData")
|
||||
.IsRequired()
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<Guid>("ProspectId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProspectId");
|
||||
|
||||
b.ToTable("ProspectImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("EncryptedPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("ForceLogout")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Groups")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Mail")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Memo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Network")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ResetToken")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("ResetTokenExpiry")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("Verified")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserID");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect")
|
||||
.WithMany("Interactions")
|
||||
.HasForeignKey("ProspectID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User")
|
||||
.WithMany("Interactions")
|
||||
.HasForeignKey("UserID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Prospect");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ProspectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Prospect");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
|
||||
b.Navigation("Interactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
|
||||
{
|
||||
b.Navigation("Interactions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddImageVerification : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "VerificationToken",
|
||||
table: "Prospects",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProspectImages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
ProspectId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
ImageData = table.Column<byte[]>(type: "BLOB", nullable: false),
|
||||
ContentType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProspectImages", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProspectImages_Prospects_ProspectId",
|
||||
column: x => x.ProspectId,
|
||||
principalTable: "Prospects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProspectImages_ProspectId",
|
||||
table: "ProspectImages",
|
||||
column: "ProspectId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProspectImages");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VerificationToken",
|
||||
table: "Prospects");
|
||||
}
|
||||
}
|
||||
}
|
||||
264
FoodsharingSiegen.Server/Migrations/20260426081244_RemoveUserVerified.Designer.cs
generated
Normal file
@@ -0,0 +1,264 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(FsContext))]
|
||||
[Migration("20260426081244_RemoveUserVerified")]
|
||||
partial class RemoveUserVerified
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Data1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Data2")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("UserID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Audits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Alert")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Feedback")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FeedbackInfo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Info1")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Info2")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("NotNeeded")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("ProspectID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("UserID")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProspectID");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Interactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("FsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Memo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("Modified")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("RecordState")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("VerificationToken")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Warning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Prospects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<byte[]>("ImageData")
|
||||
.IsRequired()
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<Guid>("ProspectId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProspectId");
|
||||
|
||||
b.ToTable("ProspectImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("EncryptedPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("ForceLogout")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Groups")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Mail")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Memo")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Network")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ResetToken")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("ResetTokenExpiry")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Audit", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserID");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Interaction", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect")
|
||||
.WithMany("Interactions")
|
||||
.HasForeignKey("ProspectID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.User", "User")
|
||||
.WithMany("Interactions")
|
||||
.HasForeignKey("UserID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Prospect");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ProspectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Prospect");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
|
||||
b.Navigation("Interactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
|
||||
{
|
||||
b.Navigation("Interactions");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodsharingSiegen.Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RemoveUserVerified : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Verified",
|
||||
table: "Users");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Verified",
|
||||
table: "Users",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,9 @@ namespace FoodsharingSiegen.Server.Migrations
|
||||
b.Property<int>("RecordState")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid?>("VerificationToken")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("Warning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -126,6 +129,34 @@ namespace FoodsharingSiegen.Server.Migrations
|
||||
b.ToTable("Prospects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<byte[]>("ImageData")
|
||||
.IsRequired()
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<Guid>("ProspectId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProspectId");
|
||||
|
||||
b.ToTable("ProspectImages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -169,9 +200,6 @@ namespace FoodsharingSiegen.Server.Migrations
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("Verified")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
@@ -205,8 +233,21 @@ namespace FoodsharingSiegen.Server.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.ProspectImage", b =>
|
||||
{
|
||||
b.HasOne("FoodsharingSiegen.Contracts.Entity.Prospect", "Prospect")
|
||||
.WithMany("Images")
|
||||
.HasForeignKey("ProspectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Prospect");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.Prospect", b =>
|
||||
{
|
||||
b.Navigation("Images");
|
||||
|
||||
b.Navigation("Interactions");
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
<DataGrid TItem="Audit"
|
||||
Data="@Audits"
|
||||
ReadData="@OnReadData"
|
||||
TotalItems="@TotalAudits"
|
||||
VirtualizeOptions="@(new() { DataGridHeight = "100%", DataGridMaxHeight = "100%"})"
|
||||
Virtualize="true"
|
||||
Responsive>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Blazorise.DataGrid;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Helper;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -26,16 +28,47 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
/// </summary>
|
||||
private List<Audit>? Audits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the total audits (ab)
|
||||
/// </summary>
|
||||
private int TotalAudits { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task InitializeDataAsync()
|
||||
protected override Task InitializeDataAsync()
|
||||
{
|
||||
var loadR = await AuditService?.Load(100)!;
|
||||
if (loadR.Success)
|
||||
Audits = loadR.Data;
|
||||
if (!CurrentUser.IsAdmin()) NavigationManager.NavigateTo("/");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OnReadData
|
||||
|
||||
/// <summary>
|
||||
/// Called when data is read (ab)
|
||||
/// </summary>
|
||||
/// <param name="e">The params</param>
|
||||
private async Task OnReadData(DataGridReadDataEventArgs<Audit> e)
|
||||
{
|
||||
if (!CurrentUser.IsAdmin()) return;
|
||||
|
||||
var countLoad = await AuditService?.GetCount()!;
|
||||
if (countLoad.Success)
|
||||
TotalAudits = countLoad.Data;
|
||||
|
||||
// Default fallback if VirtualizeCount is not set, though Blazor shouldn't do this usually
|
||||
var limit = e.VirtualizeCount > 0 ? e.VirtualizeCount : 50;
|
||||
var offset = e.VirtualizeOffset;
|
||||
|
||||
var itemsLoad = await AuditService?.LoadPage(offset, limit)!;
|
||||
if (itemsLoad.Success)
|
||||
Audits = itemsLoad.Data;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.p-audit > ::deep form {
|
||||
height: calc(100% - 68px);
|
||||
}
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
<PageTitle>@AppSettings.Terms.Title - Passwort vergessen</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center" style="min-height: 100vh; background-color: #f4f6f8;">
|
||||
<div class="d-flex justify-content-center align-items-center-sm" style="min-height: 100vh; align-items: start;">
|
||||
<div class="card shadow border-0" style="width: 100%; max-width: 420px; border-radius: 12px; margin: 1rem;">
|
||||
|
||||
<div class="card-body p-4 p-md-5">
|
||||
<div class="text-center mb-4">
|
||||
<i class="fa-solid fa-leaf mb-3" style="font-size: 3rem; color: #64ae24;"></i>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;" class="d-block">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<p class="text-muted">Passwort zurücksetzen</p>
|
||||
</div>
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
{
|
||||
<div class="alert alert-success text-center">
|
||||
Wenn ein Benutzerkonto mit dieser E-Mail-Adresse existiert, wurde eine E-Mail mit weiteren Anweisungen versendet.
|
||||
<br><br>
|
||||
<small><b>Hinweis:</b> Bitte überprüfe auch deinen Spam-Ordner, falls du künftige E-Mails nicht im regulären Posteingang findest.</small>
|
||||
</div>
|
||||
<div class="text-center mt-4">
|
||||
<a href="/login" class="btn btn-outline-primary"><i class="fas fa-arrow-left mr-2"></i> Zurück zum Login</a>
|
||||
@@ -27,6 +29,13 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (!string.IsNullOrEmpty(ErrorMessage))
|
||||
{
|
||||
<div class="alert alert-danger text-center">
|
||||
@ErrorMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
|
||||
<Field>
|
||||
<FieldLabel>E-Mail Adresse</FieldLabel>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Server.BaseClasses;
|
||||
using FoodsharingSiegen.Server.Auth;
|
||||
@@ -15,20 +16,31 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
|
||||
public bool IsSubmitted { get; set; }
|
||||
public bool IsLoading { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
|
||||
public async Task SubmitRequest()
|
||||
{
|
||||
if (IsValidMail != ValidationStatus.Success) return;
|
||||
|
||||
IsLoading = true;
|
||||
ErrorMessage = null;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
try
|
||||
{
|
||||
await AuthService.InitiatePasswordReset(MailAddress, NavigationManager.BaseUri);
|
||||
|
||||
IsSubmitted = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ErrorMessage = "Es gab ein Problem bei der Verarbeitung der Anfrage. Bitte versuche es später erneut oder wende dich an einen Administrator.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task TextEdit_KeyUp(KeyboardEventArgs e)
|
||||
{
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
<PageTitle>@AppSettings.Terms.Title - Login</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center" style="min-height: 100vh; background-color: #f4f6f8;">
|
||||
<div class="d-flex justify-content-center align-items-center-sm" style="min-height: 100vh; align-items: start;">
|
||||
<div class="card shadow border-0" style="width: 100%; max-width: 420px; border-radius: 12px; margin: 1rem;">
|
||||
|
||||
<div class="card-body p-4 p-md-5">
|
||||
<div class="text-center mb-4">
|
||||
<i class="fa-solid fa-leaf mb-3" style="font-size: 3rem; color: #64ae24;"></i>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;" class="d-block">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<p class="text-muted">Bitte melde dich an, um fortzufahren.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
if (loginR.Success)
|
||||
NavigationManager.NavigateTo("/", true);
|
||||
else
|
||||
LoginErrorMessage = "E-Mail-Adresse oder Passwort ist ungültig.";
|
||||
LoginErrorMessage = loginR.ErrorMessage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
<TextEdit @bind-Text="User.Mail" ReadOnly="true"></TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
@* <Validation Validator="ValidationRule.None"> *@
|
||||
@* <Field ColumnSize="ColumnSize.Is12"> *@
|
||||
@* <FieldLabel>Info über dich</FieldLabel> *@
|
||||
@* <FieldBody> *@
|
||||
@* <MemoEdit Rows="3" Placeholder="z.B. Bieb bei Rewe Musterhausen" @bind-Text="User.Memo"/> *@
|
||||
@* </FieldBody> *@
|
||||
@* </Field> *@
|
||||
@* </Validation> *@
|
||||
<Validation Validator="ValidationRule.None">
|
||||
<Field ColumnSize="ColumnSize.Is12">
|
||||
<FieldLabel>Info über dich</FieldLabel>
|
||||
<FieldBody>
|
||||
<MemoEdit Rows="3" Placeholder="z.B. Bieb bei Rewe Musterhausen" @bind-Text="User.Memo"/>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</Validations>
|
||||
</Fields>
|
||||
</div>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
@inherits FsBase
|
||||
|
||||
<PageTitle>Neue Foodsaver - @AppSettings.Terms.Title</PageTitle>
|
||||
<h2>Neue Foodsaver</h2>
|
||||
<PageTitle>Aktuelle - @AppSettings.Terms.Title</PageTitle>
|
||||
<h2>Aktuelle Einarbeitungen</h2>
|
||||
|
||||
@if (AppSettings.TestMode)
|
||||
{
|
||||
@@ -17,25 +17,23 @@
|
||||
|
||||
<Button
|
||||
Color="Color.Primary"
|
||||
Width="Width.Px(50)"
|
||||
Height="Height.Px(50)"
|
||||
title="Hinzufügen"
|
||||
style="min-width: auto;"
|
||||
Clicked="@CreateProspectAsync"
|
||||
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
|
||||
><i class="fa-solid fa-plus"></i>
|
||||
><i class="fa-solid fa-plus"></i> Neu
|
||||
</Button>
|
||||
|
|
||||
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspects" OnSortChanged="StateHasChanged" />
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspects" OnSortChanged="StateHasChanged" Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.OnBoarding" />
|
||||
|
||||
@{
|
||||
var filterList = ProspectList.ApplyFilter(Filter);
|
||||
var sortList = filterList.ApplySort(CurrentSort);
|
||||
}
|
||||
|
||||
<hr/>
|
||||
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.OnBoarding"></ProspectFilterControl>
|
||||
<hr />
|
||||
|
||||
<ProspectGrid
|
||||
Prospects="sortList"
|
||||
OnDataChanged="@LoadProspects"
|
||||
|
||||
@@ -14,16 +14,13 @@
|
||||
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
|
||||
}
|
||||
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsAll" OnSortChanged="StateHasChanged" />
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsAll" OnSortChanged="StateHasChanged" Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.All" />
|
||||
|
||||
@{
|
||||
var filterList = ProspectList.ApplyFilter(Filter);
|
||||
var sortList = filterList.ApplySort(CurrentSort);
|
||||
}
|
||||
|
||||
<hr/>
|
||||
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.All"></ProspectFilterControl>
|
||||
<hr />
|
||||
<ProspectGrid
|
||||
Prospects="sortList"
|
||||
OnDataChanged="@LoadProspects"
|
||||
|
||||
@@ -5,24 +5,21 @@
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
@inherits FsBase
|
||||
|
||||
<PageTitle>Abgeschlossen - @AppSettings.Terms.Title</PageTitle>
|
||||
<h2>Abgeschlossen</h2>
|
||||
<PageTitle>Fertige - @AppSettings.Terms.Title</PageTitle>
|
||||
<h2>Abgeschlossene Einarbeitungen</h2>
|
||||
|
||||
@if (AppSettings.TestMode)
|
||||
{
|
||||
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
|
||||
}
|
||||
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsDone" OnSortChanged="StateHasChanged" />
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsDone" OnSortChanged="StateHasChanged" Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Completed" />
|
||||
|
||||
@{
|
||||
var filterList = ProspectList.ApplyFilter(Filter);
|
||||
var sortList = filterList.ApplySort(CurrentSort);
|
||||
}
|
||||
|
||||
<hr />
|
||||
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Completed"></ProspectFilterControl>
|
||||
<hr />
|
||||
<ProspectGrid
|
||||
Prospects="sortList"
|
||||
OnDataChanged="@LoadProspects"
|
||||
|
||||
@@ -6,23 +6,21 @@
|
||||
@inherits FsBase
|
||||
|
||||
<PageTitle>Freischalten - @AppSettings.Terms.Title</PageTitle>
|
||||
<h2>Freischalten</h2>
|
||||
<h2>Zum Freischalten freigegeben</h2>
|
||||
|
||||
@if (AppSettings.TestMode)
|
||||
{
|
||||
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
|
||||
}
|
||||
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsVerify" OnSortChanged="StateHasChanged" />
|
||||
<ProspectSortControl @bind-CurrentSort="CurrentSort" StorageKey="@StorageKeys.SortProspectsVerify" OnSortChanged="StateHasChanged" Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Verification" />
|
||||
|
||||
@{
|
||||
var filterList = ProspectList.ApplyFilter(Filter);
|
||||
var sortList = filterList.ApplySort(CurrentSort);
|
||||
}
|
||||
|
||||
<hr/>
|
||||
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Verification"></ProspectFilterControl>
|
||||
<hr />
|
||||
|
||||
<ProspectGrid
|
||||
Prospects="sortList"
|
||||
OnDataChanged="@LoadProspects"
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
<PageTitle>@AppSettings.Terms.Title - Neues Passwort setzen</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-center align-items-center" style="min-height: 100vh; background-color: #f4f6f8;">
|
||||
<div class="d-flex justify-content-center align-items-center-sm" style="min-height: 100vh; align-items: start;">
|
||||
<div class="card shadow border-0" style="width: 100%; max-width: 420px; border-radius: 12px; margin: 1rem;">
|
||||
|
||||
<div class="card-body p-4 p-md-5">
|
||||
<div class="text-center mb-4">
|
||||
<i class="fa-solid fa-leaf mb-3" style="font-size: 3rem; color: #64ae24;"></i>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<h4 class="font-weight-bold" style="color: #533a20;"><small style="font-size: .6em;" class="d-block">Einarbeitungen</small> @AppSettings.Terms.Title</h4>
|
||||
<p class="text-muted">Neues Passwort festlegen</p>
|
||||
</div>
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info" style="font-size: 0.85rem;">
|
||||
<i class="fas fa-info-circle mr-1"></i> Dein Passwort muss mindestens 8 Zeichen lang sein und eine Zahl enthalten.
|
||||
</div>
|
||||
|
||||
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">
|
||||
<Field>
|
||||
<FieldLabel>Neues Passwort</FieldLabel>
|
||||
|
||||
123
FoodsharingSiegen.Server/Pages/UploadVerification.razor
Normal file
@@ -0,0 +1,123 @@
|
||||
@page "/verify/{Token:guid}"
|
||||
@using FoodsharingSiegen.Contracts.Entity
|
||||
@using System.IO
|
||||
@layout LoginLayout
|
||||
|
||||
<PageTitle>Identitätsprüfung - @AppSettings.Value.Terms.Title</PageTitle>
|
||||
|
||||
<div class="row min-vh-100 align-items-center-sm justify-content-center p-0 p-md-5 m-0">
|
||||
<div class="col-12 col-md-10 col-lg-8 col-xl-5 login-form p-2">
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-3 p-md-5">
|
||||
<div class="text-center mb-4">
|
||||
|
||||
<h5 class="mb-0 text-success d-block d-sm-none"><i
|
||||
class="fa-solid fa-address-card me-2"></i><br>Identitätsprüfung</h5>
|
||||
<h4 class="mb-0 text-success d-none d-sm-block"><i
|
||||
class="fa-solid fa-address-card me-2"></i>Identitätsprüfung</h4>
|
||||
|
||||
<p class="text-muted mt-2">@(AppSettings.Value.Terms.Title)</p>
|
||||
</div>
|
||||
|
||||
@if (_isLoading)
|
||||
{
|
||||
<div class="text-center my-5">
|
||||
<div class="spinner-border text-success" role="status">
|
||||
<span class="visually-hidden">Laden...</span>
|
||||
</div>
|
||||
<p class="mt-3 text-muted">Lade Daten...</p>
|
||||
</div>
|
||||
}
|
||||
else if (_prospect == null)
|
||||
{
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<i class="fa-solid fa-triangle-exclamation me-2"></i> @(_message ?? "Der Link ist ungültig oder abgelaufen. Bitte fordere einen neuen Link an.")
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info mb-4">
|
||||
<strong>Hinweis:</strong> Dies ist die Upload-Seite für Foodsaver <b>@_prospect.FsId</b>.
|
||||
</div>
|
||||
|
||||
<div class="mb-3 text-center">
|
||||
|
||||
@if (_uploadedCount >= 5)
|
||||
{
|
||||
<div class="alert alert-warning py-2 mb-0">Du hast die maximale Anzahl von 5 Bildern erreicht.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<InputFile id="fileInput" OnChange="OnInputFileChange" class="d-none" accept="image/*" />
|
||||
<label for="fileInput" class="btn btn-outline-success w-100" style="height: 5rem;">
|
||||
<i class="fa-solid fa-images me-2"></i>Bild auswählen
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_message))
|
||||
{
|
||||
<div class="alert alert-@(_isSuccess ? "success" : "danger") alert-dismissible fade show" role="alert">
|
||||
@_message
|
||||
<button type="button" class="btn-close" @onclick="() => _message = null"></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (_isSuccess)
|
||||
{
|
||||
<div class="alert alert-success text-center">
|
||||
<i class="fa-solid fa-check-circle fa-2x mb-2"></i><br />
|
||||
Vielen Dank für den Upload. Wenn du alle benötigten Bilder hochgeladen hast, kannst du die Seite
|
||||
schließen. Du musst nichts weiter tun.
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (_uploadedCount < 5)
|
||||
{
|
||||
<div class="text-center mb-3">
|
||||
<span class="badge bg-secondary text-wrap">Es können noch bis zu @(5 - _uploadedCount) Bilder
|
||||
hochgeladen werden</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="mb-1 text-muted">
|
||||
Um dich auf der Foodsharing-Plattform als Foodsaver freischalten zu können, muss ein*e
|
||||
Botschafter*in Name, Adresse und Geburtsdatum im Profil des Foodsavers auf Korrektheit durch
|
||||
Vergleich mit einem Ausweisdokument prüfen. Das ist wichtig, damit die <a
|
||||
href="https://wiki.foodsharing.network/wiki/Rechtsvereinbarung"
|
||||
target="_blank">Rechtsvereinbarung</a> Bestand hat und wir die Zusagen erfüllen, die wir den
|
||||
Spenderbetrieben geben.<br>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 text-muted">
|
||||
<a class="mt-3"
|
||||
href="https://wiki.foodsharing.network/wiki/Foodsaver#3.4_Verifizierung_(der_Daten),_Foodsaver-Ausweis_und_Freischaltung"
|
||||
target="_blank">Mehr dazu im Wiki</a>.
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<h5 class="fw-bold">Anleitung:</h5>
|
||||
<ul class="text-muted">
|
||||
<li>Lade hier die Vorder- und Rückseite deines Personalausweises oder Reisepasses hoch</li>
|
||||
<li>Dein Name und Adresse müssen gut und lesbar erkennbar sein</li>
|
||||
<li>Wir nutzen diese Bilder ausschließlich zur Identitätsprüfung</li>
|
||||
<li>Ausschließlich die Botschafter haben Zugriff auf diese Bilder</li>
|
||||
<li>Die Bilder werden nach der Überprüfung sofort und unwiderruflich von uns gelöscht</li>
|
||||
<li>Bereits hochgeladene Bilder werden hier hier aus Datenschutzgründen nicht angezeigt</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@if (_isUploading)
|
||||
{
|
||||
<div class="text-center my-3">
|
||||
<div class="spinner-border text-primary spinner-border-sm" role="status">
|
||||
<span class="visually-hidden">Laden...</span>
|
||||
</div>
|
||||
<span class="ms-2">Bilder werden hochgeladen und verarbeitet...</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
142
FoodsharingSiegen.Server/Pages/UploadVerification.razor.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Shared.Helper;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
public partial class UploadVerification : ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
public ProspectService ProspectService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
public IOptions<AppSettings> AppSettings { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public Guid Token { get; set; }
|
||||
|
||||
private bool _isLoading = true;
|
||||
private Prospect? _prospect;
|
||||
|
||||
private int _uploadedCount = 0;
|
||||
private bool _isUploading = false;
|
||||
|
||||
private string? _message;
|
||||
private bool _isSuccess;
|
||||
|
||||
private const int MaxAllowedFiles = 5;
|
||||
private const long MaxFileSize = 10 * 1024 * 1024; // 10 MB
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
_isLoading = true;
|
||||
|
||||
try
|
||||
{
|
||||
var result = await ProspectService.GetProspectByVerificationTokenAsync(Token);
|
||||
|
||||
if (result.Success && result.Data != null)
|
||||
{
|
||||
_prospect = result.Data;
|
||||
_uploadedCount = _prospect.Images?.Count ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_prospect = null;
|
||||
_message = result.Exception?.Message ?? "Ein Fehler ist aufgetreten.";
|
||||
_isSuccess = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_message = $"Fehler: {ex.Message}";
|
||||
_isSuccess = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnInputFileChange(InputFileChangeEventArgs e)
|
||||
{
|
||||
if (_prospect == null) return;
|
||||
|
||||
_message = null;
|
||||
|
||||
var files = e.GetMultipleFiles(MaxAllowedFiles);
|
||||
|
||||
if (_uploadedCount + files.Count > MaxAllowedFiles)
|
||||
{
|
||||
_message = $"Es sind maximal {MaxAllowedFiles} Bilder erlaubt.";
|
||||
_isSuccess = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_isUploading = true;
|
||||
|
||||
int successCount = 0;
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (file.Size > MaxFileSize)
|
||||
{
|
||||
_message = $"Bild '{file.Name}' überschreitet die erlaubte Größe von 10 MB.";
|
||||
_isSuccess = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resize the image to a max dimension of 1000 pixels (longest edge) to save DB space
|
||||
var resizedImageFile = await file.RequestImageFileAsync(file.ContentType, 1000, 1000);
|
||||
|
||||
using var stream = resizedImageFile.OpenReadStream(MaxFileSize);
|
||||
using var memoryStream = new MemoryStream();
|
||||
|
||||
await stream.CopyToAsync(memoryStream);
|
||||
|
||||
byte[] imageData = memoryStream.ToArray();
|
||||
|
||||
var saveResult = await ProspectService.AddVerificationImageAsync(_prospect.Id, imageData, resizedImageFile.ContentType);
|
||||
|
||||
if (saveResult.Success)
|
||||
{
|
||||
successCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_message = $"Fehler beim Speichern von {file.Name}: {saveResult.Exception?.Message}";
|
||||
_isSuccess = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_message = $"Fehler bei {file.Name}: {ex.Message}";
|
||||
_isSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
_isUploading = false;
|
||||
|
||||
if (successCount > 0)
|
||||
{
|
||||
_message = $"{successCount} Bild(er) erfolgreich hinzugefügt.";
|
||||
_isSuccess = true;
|
||||
_uploadedCount += successCount;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,111 +6,137 @@
|
||||
|
||||
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
|
||||
|
||||
@code {
|
||||
|
||||
private RenderFragment PopupTitleTemplate(PopupTitleContext<User> value)
|
||||
{
|
||||
var header = "Benutzer erstellen";
|
||||
if (value.EditState == DataGridEditState.Edit) header = "Benutzer bearbeiten";
|
||||
|
||||
return builder =>
|
||||
{
|
||||
builder.OpenElement(0, "span");
|
||||
builder.AddContent(1, header);
|
||||
builder.CloseElement();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<PageTitle>Benutzerverwaltung - @AppSettings.Terms.Title</PageTitle>
|
||||
|
||||
<h2>Benutzerverwaltung <span style="font-size: .5em; line-height: 0;">Admin</span></h2>
|
||||
|
||||
<div class="my-2">
|
||||
<Button Color="Color.Primary" Disabled="@(SelectedUser == null)" Clicked="async () => await PasswordModal?.Show(SelectedUser!)!"><i class="fa-solid fa-key"></i> setzen</Button>
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h2>Benutzerverwaltung <span style="font-size: .5em; line-height: 0;">Admin</span></h2>
|
||||
<Button Color="Color.Success" Clicked="CreateNewUser">
|
||||
<Icon Name="IconName.Add" /> Benutzer erstellen
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<DataGrid TItem="User"
|
||||
@ref="UserDataGrid"
|
||||
Data="@UserList"
|
||||
CommandMode="DataGridCommandMode.Commands"
|
||||
EditMode="DataGridEditMode.Popup"
|
||||
PopupTitleTemplate="PopupTitleTemplate"
|
||||
RowInserted="RowInserted"
|
||||
RowUpdated="RowUpdated"
|
||||
PageSize="50"
|
||||
@bind-SelectedRow="SelectedUser"
|
||||
RowDoubleClicked="arg => UserDataGrid?.Edit(arg.Item)!"
|
||||
Editable
|
||||
Responsive="true">
|
||||
<DataGridColumns>
|
||||
<DataGridCommandColumn TItem="User" Width="100px" CellClass="@(_ => "px-0 d-flex align-items-center justify-content-center")">
|
||||
<NewCommandTemplate>
|
||||
<Button Size="Size.ExtraSmall" Color="Color.Success" Clicked="@context.Clicked" Class="mr-1" Style="min-width: auto;">
|
||||
<i class="oi oi-plus"></i>
|
||||
</Button>
|
||||
</NewCommandTemplate>
|
||||
<EditCommandTemplate>
|
||||
<Button Size="Size.ExtraSmall" Color="Color.Secondary" Clicked="@context.Clicked" Class="mr-1" Style="min-width: auto;">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</Button>
|
||||
</EditCommandTemplate>
|
||||
<DeleteCommandTemplate>
|
||||
<Button Size="Size.ExtraSmall" Color="Color.Danger" Clicked="() => RemoveUserAsync(context.Item)" Class="mr-1" Style="min-width: auto;">
|
||||
<i class="oi oi-trash"></i>
|
||||
</Button>
|
||||
</DeleteCommandTemplate>
|
||||
<ClearFilterCommandTemplate>
|
||||
<Button Size="Size.ExtraSmall" Color="Color.Danger" Clicked="@context.Clicked" Style="min-width: auto;">
|
||||
<i class="o"></i> <i class="fas fa-trash"></i>
|
||||
</Button>
|
||||
</ClearFilterCommandTemplate>
|
||||
</DataGridCommandColumn>
|
||||
<DataGridCheckColumn TItem="User" Field="@nameof(User.Verified)" Caption="Verifiziert" Editable="true" Width="100px">
|
||||
<DisplayTemplate>
|
||||
<Check TValue="bool" Checked="context.Verified" Disabled="true" ReadOnly="true"/>
|
||||
</DisplayTemplate>
|
||||
</DataGridCheckColumn>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.Type)" Caption="Typ" Editable="true" Width="200px">
|
||||
<EditTemplate>
|
||||
<Select TValue="UserType" SelectedValue="@((UserType)context.CellValue)" SelectedValueChanged="@(v => context.CellValue = v)">
|
||||
<div class="user-grid" style="max-width: 1000px;">
|
||||
@if (SortedUsers != null)
|
||||
{
|
||||
@foreach (var user in SortedUsers)
|
||||
{
|
||||
<Card Class="user-card">
|
||||
<CardBody>
|
||||
<CardTitle Size="4">@user.Name</CardTitle>
|
||||
<CardSubtitle Class="mb-2 text-muted">@user.Mail</CardSubtitle>
|
||||
<CardText>
|
||||
Typ:
|
||||
@if (user.Type == UserType.Unverified)
|
||||
{
|
||||
<span style="color: red" class="fw-bold">@user.Type</span>
|
||||
}
|
||||
else if (user.Type == UserType.Admin)
|
||||
{
|
||||
<span style="color: blue" class="fw-bold">@user.Type</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@user.Type
|
||||
}
|
||||
</CardText>
|
||||
|
||||
<div class="mb-3">
|
||||
@if (user.GroupsList != null && user.GroupsList.Any())
|
||||
{
|
||||
@foreach(var group in user.GroupsList)
|
||||
{
|
||||
<Badge Color="Color.Primary" Class="me-1" Style="font-size: 0.8em;">@group.ToString()</Badge>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-muted" style="font-style: italic; font-size: 0.8em;">Keine Gruppen</span>
|
||||
}
|
||||
</div>
|
||||
</CardBody>
|
||||
<CardFooter Class="d-flex justify-content-between">
|
||||
<Button Color="Color.Primary" Size="Size.Small" Clicked="() => EditUser(user)"><Icon Name="IconName.Edit" /></Button>
|
||||
<Button Color="Color.Info" Size="Size.Small" Clicked="() => SetPassword(user)"><i class="fa-solid fa-key"></i></Button>
|
||||
<Button Color="Color.Secondary" Size="Size.Small" Clicked="() => SendPasswordSetupMail(user)"><Icon Name="IconName.Mail" /></Button>
|
||||
@if (!(user.Type == UserType.Admin && SortedUsers.Count(x => x.Type == UserType.Admin) <= 1))
|
||||
{
|
||||
<Button Color="Color.Danger" Size="Size.Small" Clicked="() => RemoveUserAsync(user)"><Icon Name="IconName.Delete" /></Button>
|
||||
}
|
||||
</CardFooter>
|
||||
</Card>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.user-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
gap: 1rem;
|
||||
}
|
||||
@@media (min-width: 700px) {
|
||||
.user-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@@media (min-width: 1250px) {
|
||||
.user-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<Modal @ref="editUserModal">
|
||||
<ModalContent Centered>
|
||||
<ModalHeader>
|
||||
<ModalTitle>@(IsEditing ? "Benutzer bearbeiten" : "Benutzer erstellen")</ModalTitle>
|
||||
<CloseButton />
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
@if (EditModel != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>Name</FieldLabel>
|
||||
<TextEdit @bind-Text="EditModel.Name" />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>E-Mail</FieldLabel>
|
||||
<TextEdit @bind-Text="EditModel.Mail" />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Typ</FieldLabel>
|
||||
<Select TValue="UserType" SelectedValue="EditModel.Type" SelectedValueChanged="@(v => EditModel.Type = v)" Disabled="@IsLastAdmin">
|
||||
@foreach (var enumValue in Enum.GetValues<UserType>())
|
||||
{
|
||||
<SelectItem TValue="UserType" Value="enumValue">@enumValue</SelectItem>
|
||||
}
|
||||
</Select>
|
||||
</EditTemplate>
|
||||
</DataGridColumn>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.Name)" Caption="Name" Editable="true" Width="250px"></DataGridColumn>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.Mail)" Caption="E-Mail" Editable="true"></DataGridColumn>
|
||||
<DataGridColumn TItem="User" Field="@nameof(User.GroupsList)" Caption="Gruppen" Editable="true">
|
||||
<EditTemplate>
|
||||
@if (IsLastAdmin)
|
||||
{
|
||||
<small class="text-danger mt-1 d-block">Das ist der letzte Administrator-Account. Der Typ kann nicht geändert werden.</small>
|
||||
}
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Gruppen</FieldLabel>
|
||||
<Autocomplete TItem="UserGroup"
|
||||
TValue="UserGroup"
|
||||
Size="Size.ExtraSmall"
|
||||
Data="@UserGroups"
|
||||
TextField="@(( item ) => item.ToString())"
|
||||
ValueField="@(( item ) => item)"
|
||||
Multiple="true"
|
||||
SelectedValues="@((List<UserGroup>) context.CellValue)"
|
||||
SelectedValuesChanged="@(v => context.CellValue = v)"
|
||||
@bind-SelectedTexts="SelectedCompanyTexts">
|
||||
SelectionMode="AutocompleteSelectionMode.Multiple"
|
||||
SelectedValues="@EditModel.GroupsList"
|
||||
SelectedValuesChanged="@(v => { EditModel.GroupsList = v.ToList(); })"
|
||||
@bind-SelectedTexts="SelectedGroupTexts">
|
||||
</Autocomplete>
|
||||
<small>Verfügbar: @string.Join(", ", Enum.GetValues<UserGroup>())</small>
|
||||
</EditTemplate>
|
||||
<DisplayTemplate>
|
||||
@if (string.IsNullOrWhiteSpace(context.Groups))
|
||||
{
|
||||
<span style="font-style: italic;">Keine Gruppen</span>
|
||||
</Field>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>@string.Join(", ", context.GroupsList)</span>
|
||||
}
|
||||
</DisplayTemplate>
|
||||
</DataGridColumn>
|
||||
</DataGridColumns>
|
||||
</DataGrid>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button Color="Color.Secondary" Clicked="() => editUserModal?.Hide()">Abbrechen</Button>
|
||||
<Button Color="Color.Primary" Clicked="SaveUser">Speichern</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
||||
<SetPasswordModal @ref="PasswordModal" OnPasswortSet="OnPasswordSet"></SetPasswordModal>
|
||||
@@ -1,4 +1,4 @@
|
||||
using Blazorise.DataGrid;
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Enums;
|
||||
using FoodsharingSiegen.Contracts.Helper;
|
||||
@@ -22,6 +22,12 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
[Inject]
|
||||
public UserService UserService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
public new FoodsharingSiegen.Server.Auth.AuthService AuthService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
public new NavigationManager NavigationManager { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
@@ -32,19 +38,29 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
private SetPasswordModal? PasswordModal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the selected company texts (ab)
|
||||
/// Gets or sets the edit user modal
|
||||
/// </summary>
|
||||
private List<string> SelectedCompanyTexts { get; set; } = new();
|
||||
private Modal? editUserModal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the selected user (ab)
|
||||
/// Gets or sets the selected group texts
|
||||
/// </summary>
|
||||
private User? SelectedUser { get; set; }
|
||||
private List<string> SelectedGroupTexts { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the user data grid (ab)
|
||||
/// Gets or sets the edit model
|
||||
/// </summary>
|
||||
private DataGrid<User>? UserDataGrid { get; set; }
|
||||
private User? EditModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether we are editing an existing user
|
||||
/// </summary>
|
||||
private bool IsEditing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current editing user is the last admin
|
||||
/// </summary>
|
||||
private bool IsLastAdmin => IsEditing && EditModel?.Type == UserType.Admin && UserList?.Count(x => x.Type == UserType.Admin) <= 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the user groups (ab)
|
||||
@@ -56,6 +72,11 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
/// </summary>
|
||||
private List<User>? UserList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sorted users list
|
||||
/// </summary>
|
||||
private IEnumerable<User> SortedUsers => UserList?.OrderByDescending(x => x.Type).ThenBy(x => x.Name) ?? Enumerable.Empty<User>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
@@ -84,6 +105,66 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
|
||||
#endregion
|
||||
|
||||
#region Actions
|
||||
|
||||
private void CreateNewUser()
|
||||
{
|
||||
EditModel = new User();
|
||||
IsEditing = false;
|
||||
editUserModal?.Show();
|
||||
}
|
||||
|
||||
private void EditUser(User user)
|
||||
{
|
||||
EditModel = user.Clone();
|
||||
IsEditing = true;
|
||||
editUserModal?.Show();
|
||||
}
|
||||
|
||||
private void SetPassword(User user)
|
||||
{
|
||||
PasswordModal?.Show(user);
|
||||
}
|
||||
|
||||
private async Task SendPasswordSetupMail(User user)
|
||||
{
|
||||
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Soll eine E-Mail zum Festlegen des Passworts an {user.Mail} gesendet werden?", async () =>
|
||||
{
|
||||
await AuthService.InitiateInitialPasswordSetup(user.Mail, NavigationManager.BaseUri);
|
||||
if (Notification != null)
|
||||
{
|
||||
await Notification.Success("E-Mail gesendet. Bitte weise den Benutzer darauf hin, auch den Spam-Ordner zu prüfen.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
if (EditModel == null) return;
|
||||
|
||||
if (IsEditing)
|
||||
{
|
||||
var updateR = await UserService.Update(EditModel);
|
||||
if (!updateR.Success)
|
||||
await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!;
|
||||
else
|
||||
await Notification.Success("Benutzer aktualisiert");
|
||||
}
|
||||
else
|
||||
{
|
||||
var addUserR = await UserService.AddUserAsync(EditModel);
|
||||
if (!addUserR.Success)
|
||||
await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
||||
else
|
||||
await Notification.Success("Benutzer erstellt");
|
||||
}
|
||||
|
||||
await editUserModal?.Hide()!;
|
||||
await LoadUsers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OnPasswordSet
|
||||
|
||||
/// <summary>
|
||||
@@ -108,12 +189,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
/// <returns>A task that represents the asynchronous remove operation.</returns>
|
||||
private async Task RemoveUserAsync(User user)
|
||||
{
|
||||
if (user.IsAdmin())
|
||||
{
|
||||
await Notification.Error("Admins können nicht gelöscht werden!");
|
||||
return;
|
||||
}
|
||||
|
||||
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"User {user.Mail} löschen?", async () =>
|
||||
{
|
||||
var removeR = await UserService.RemoveAsync(user.Id);
|
||||
@@ -125,39 +200,5 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method RowInserted
|
||||
|
||||
/// <summary>
|
||||
/// Rows the inserted using the specified arg (a. beging, 01.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="arg">The arg</param>
|
||||
private async Task RowInserted(SavedRowItem<User, Dictionary<string, object>> arg)
|
||||
{
|
||||
var addUserR = await UserService.AddUserAsync(arg.Item);
|
||||
if (!addUserR.Success)
|
||||
await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
||||
else
|
||||
await LoadUsers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method RowUpdated
|
||||
|
||||
/// <summary>
|
||||
/// Rows the updated using the specified arg (a. beging, 01.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="arg">The arg</param>
|
||||
private async Task RowUpdated(SavedRowItem<User, Dictionary<string, object>> arg)
|
||||
{
|
||||
if (arg.Item?.Id == null || arg.Item.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return;
|
||||
|
||||
var updateR = await UserService.Update(arg.Item);
|
||||
if (!updateR.Success)
|
||||
await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,24 @@
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<base href="~/"/>
|
||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"/>
|
||||
<link href="css/site.css" rel="stylesheet"/>
|
||||
<link href="FoodsharingSiegen.Server.styles.css" rel="stylesheet"/>
|
||||
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-title" content="Foodsharing Einarbeitungen" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<link rel="stylesheet" href="~/css/bootstrap/bootstrap.min.css" asp-append-version="true" />
|
||||
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
|
||||
<link href="~/FoodsharingSiegen.Server.styles.css" rel="stylesheet" asp-append-version="true" />
|
||||
|
||||
<!-- Material CSS -->
|
||||
<link href="css/material.min.css" rel="stylesheet">
|
||||
<link href="~/css/material.min.css" rel="stylesheet" asp-append-version="true" />
|
||||
|
||||
<!-- Add Material font (Roboto) and Material icon as needed -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i|Roboto+Mono:300,400,700|Roboto+Slab:300,400,700" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
|
||||
<link href="css/all.min.css" rel="stylesheet" />
|
||||
<link href="~/css/all.min.css" rel="stylesheet" asp-append-version="true" />
|
||||
<link href="_content/Blazorise/blazorise.css?v=1.7.5.0" rel="stylesheet" />
|
||||
<link href="_content/Blazorise.Material/blazorise.material.css?v=1.7.5.0" rel="stylesheet" />
|
||||
<link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css?v=1.7.5.0" rel="stylesheet" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using AspNetCore.SassCompiler;
|
||||
using Blazorise;
|
||||
using Blazorise.Icons.Material;
|
||||
using Blazorise.Material;
|
||||
@@ -19,6 +20,9 @@ builder.WebHost.UseUrls("http://+:8700");
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.AddDatabaseContext();
|
||||
#if DEBUG
|
||||
builder.Services.AddSassCompiler();
|
||||
#endif
|
||||
|
||||
// DI
|
||||
builder.Services.AddScoped<LocalStorageService>();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using MailKit.Net.Smtp;
|
||||
@@ -15,15 +16,17 @@ namespace FoodsharingSiegen.Server.Service
|
||||
{
|
||||
private readonly MailSettings _mailSettings;
|
||||
private readonly TermSettings _termSettings;
|
||||
private readonly Func<ISmtpClient> _smtpClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MailService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="appSettings">The configured application settings injected by DI, containing the <see cref="MailSettings"/>.</param>
|
||||
public MailService(IOptions<AppSettings> appSettings)
|
||||
public MailService(IOptions<AppSettings> appSettings, Func<ISmtpClient>? smtpClientFactory = null)
|
||||
{
|
||||
_mailSettings = appSettings.Value.Mail;
|
||||
_termSettings = appSettings.Value.Terms;
|
||||
_smtpClientFactory = smtpClientFactory ?? (() => new SmtpClient());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -40,7 +43,7 @@ namespace FoodsharingSiegen.Server.Service
|
||||
};
|
||||
email.Body = textPart;
|
||||
|
||||
using var smtp = new SmtpClient();
|
||||
using var smtp = _smtpClientFactory();
|
||||
var secureOptions = _mailSettings.UseSsl ? SecureSocketOptions.StartTls : SecureSocketOptions.Auto;
|
||||
|
||||
await smtp.ConnectAsync(_mailSettings.Host, _mailSettings.Port, secureOptions);
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
||||
<NotificationAlert/>
|
||||
<MessageAlert/>
|
||||
<NotificationProvider/>
|
||||
<MessageProvider/>
|
||||
@@ -1,180 +0,0 @@
|
||||
.page {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.page aside {
|
||||
background-color: #f1e7c9;
|
||||
width: 0;
|
||||
box-shadow: 5px 5px 5px #acacac;
|
||||
transition: width 250ms;
|
||||
overflow: hidden auto;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
.page aside {
|
||||
width: 250px;
|
||||
min-width: 250px;
|
||||
}
|
||||
}
|
||||
|
||||
.page main {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
overflow: hidden auto;
|
||||
padding: 60px 10px 10px 10px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
.page main {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
#menu-toggler {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#menu-toggler-label {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
cursor: pointer;
|
||||
height: 30px;
|
||||
width: calc(100% - 40px);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
#menu-toggler-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
#menu-toggler-label span {
|
||||
height: 6px;
|
||||
background-color: #64ae24;
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 30px;
|
||||
transition: all 0.25s ease-out;
|
||||
}
|
||||
|
||||
#menu-toggler-label span:nth-child(2) {
|
||||
top: 12px;
|
||||
}
|
||||
|
||||
#menu-toggler-label span:nth-child(3) {
|
||||
top: 24px;
|
||||
}
|
||||
|
||||
input:checked ~ aside {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
input:checked ~ #menu-toggler-label span:nth-child(1) {
|
||||
transform: translateY(12px) rotate(45deg);
|
||||
}
|
||||
|
||||
input:checked ~ #menu-toggler-label span:nth-child(2) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input:checked ~ #menu-toggler-label span:nth-child(3) {
|
||||
transform: translateY(-12px) rotate(-45deg);
|
||||
}
|
||||
|
||||
::deep h2 {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
::deep h2 {
|
||||
font-size: 3.2rem;
|
||||
line-height: 3.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
::deep h2 {
|
||||
font-size: 3.8rem;
|
||||
line-height: 3.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
::deep h2 {
|
||||
font-size: 3.8rem;
|
||||
line-height: 3.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1200px) {
|
||||
::deep h2 {
|
||||
font-size: 3.8rem;
|
||||
line-height: 3.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1400px) {
|
||||
::deep h2 {
|
||||
font-size: 3.8rem;
|
||||
line-height: 3.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1950px) {
|
||||
::deep h2 {
|
||||
font-size: 3.2rem;
|
||||
line-height: 3.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
::deep h3 {
|
||||
font-size: 1.4rem;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 576px) {
|
||||
::deep h3 {
|
||||
font-size: 2.4rem;
|
||||
line-height: 2.4rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
::deep h3 {
|
||||
font-size: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
::deep h3 {
|
||||
font-size: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1200px) {
|
||||
::deep h3 {
|
||||
font-size: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1400px) {
|
||||
::deep h3 {
|
||||
font-size: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1950px) {
|
||||
::deep h3 {
|
||||
font-size: 2.4rem;
|
||||
line-height: 2.4rem;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ $sidebarBreakpoint: $breakpointM;
|
||||
height: 100vh;
|
||||
|
||||
aside {
|
||||
background-color: #f1e7c9;
|
||||
background-color: #f0f0f0;
|
||||
width: 0;
|
||||
box-shadow: 5px 5px 5px #acacac;
|
||||
transition: width 250ms;
|
||||
|
||||
@@ -8,11 +8,6 @@ main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
/*background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);*/
|
||||
background-color: #f1e7c9 !important;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
<nav class="d-flex flex-column h-100">
|
||||
<div class="nav-logo"></div>
|
||||
<div class="d-flex px-3 justify-content-center text-center font-weight-bold">
|
||||
Einarbeitungen<br/>
|
||||
@(AppSettings.Terms.TitleShort ?? AppSettings.Terms.Title)
|
||||
<i class="fa-solid fa-leaf mb-3 mt-3 text-center" style="font-size: 4rem; color: #64ae24;"></i>
|
||||
<div class="px-3 justify-content-center text-center font-weight-bold">
|
||||
<span class="d-block">Einarbeitungen</span>
|
||||
<h5 class="d-block">@(AppSettings.Terms.Title ?? AppSettings.Terms.TitleShort)</h5>
|
||||
</div>
|
||||
<div class="d-flex px-3 mt-3 justify-content-center text-center font-weight-bold">
|
||||
<div class="d-flex px-3 justify-content-center text-center text-muted">
|
||||
Hallo @CurrentUser.Name!
|
||||
</div>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<div @onclick="NavLinkClickedAsync">
|
||||
@@ -73,6 +72,7 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="flex-grow-1"></div>
|
||||
|
||||
@@ -92,5 +92,5 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pb-1 text-center small">@($"v{Version ?? "0"}")</div>
|
||||
<div class="pb-1 text-center small text-muted">@($"Version {Version ?? "0"}")</div>
|
||||
</nav>
|
||||
@@ -1,65 +0,0 @@
|
||||
nav {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
nav {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
nav .nav-logo {
|
||||
background-image: url(img/logo_text.png);
|
||||
height: 55px;
|
||||
width: 200px;
|
||||
margin: auto;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
nav .nav-logo {
|
||||
height: 220px;
|
||||
background-image: url(img/logo.png);
|
||||
}
|
||||
}
|
||||
|
||||
.oi {
|
||||
width: 2rem;
|
||||
font-size: 1.1rem;
|
||||
vertical-align: text-top;
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
font-size: 0.9rem;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-item:first-of-type {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.nav-item:last-of-type {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep a {
|
||||
color: #533a20;
|
||||
border-radius: 4px;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
}
|
||||
|
||||
.nav-item ::deep a.active {
|
||||
background-color: rgba(255, 255, 255, 0.25);
|
||||
color: #64ae24;
|
||||
}
|
||||
|
||||
.nav-item ::deep a:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: #64ae24;
|
||||
}
|
||||
16
FoodsharingSiegen.Server/sasscompiler.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"GenerateScopedCss": true,
|
||||
"ScopedCssFolders": [
|
||||
"Views",
|
||||
"Pages",
|
||||
"Shared",
|
||||
"Components",
|
||||
"Controls"
|
||||
],
|
||||
"Compilations" : [
|
||||
{
|
||||
"Source": "wwwroot/css/site.scss",
|
||||
"Target": "wwwroot/css/site.css"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
FoodsharingSiegen.Server/wwwroot/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
80
FoodsharingSiegen.Server/wwwroot/css/_utilities.scss
Normal file
@@ -0,0 +1,80 @@
|
||||
// Breakpoints matching typical Bootstrap breakpoints
|
||||
$breakpoints: (
|
||||
sm: 576px,
|
||||
md: 768px,
|
||||
lg: 992px,
|
||||
xl: 1200px
|
||||
);
|
||||
|
||||
// Spacer values (1 to 5) mapped to rem
|
||||
$spacers: (
|
||||
0: 0,
|
||||
1: 0.25rem,
|
||||
2: 0.5rem,
|
||||
3: 1rem,
|
||||
4: 1.5rem,
|
||||
5: 3rem
|
||||
);
|
||||
|
||||
@mixin generate-utilities($breakpoint: "") {
|
||||
@each $size-key, $size-val in $spacers {
|
||||
|
||||
// Padding and Margin (all sides)
|
||||
.p#{$breakpoint}-#{$size-key} { padding: $size-val !important; }
|
||||
.m#{$breakpoint}-#{$size-key} { margin: $size-val !important; }
|
||||
|
||||
// Top
|
||||
.pt#{$breakpoint}-#{$size-key} { padding-top: $size-val !important; }
|
||||
.mt#{$breakpoint}-#{$size-key} { margin-top: $size-val !important; }
|
||||
|
||||
// Right / End
|
||||
.pr#{$breakpoint}-#{$size-key} { padding-right: $size-val !important; }
|
||||
.mr#{$breakpoint}-#{$size-key} { margin-right: $size-val !important; }
|
||||
|
||||
// Bottom
|
||||
.pb#{$breakpoint}-#{$size-key} { padding-bottom: $size-val !important; }
|
||||
.mb#{$breakpoint}-#{$size-key} { margin-bottom: $size-val !important; }
|
||||
|
||||
// Left / Start
|
||||
.pl#{$breakpoint}-#{$size-key} { padding-left: $size-val !important; }
|
||||
.ml#{$breakpoint}-#{$size-key} { margin-left: $size-val !important; }
|
||||
|
||||
// X-axis (left and right)
|
||||
.px#{$breakpoint}-#{$size-key} {
|
||||
padding-left: $size-val !important;
|
||||
padding-right: $size-val !important;
|
||||
}
|
||||
.mx#{$breakpoint}-#{$size-key} {
|
||||
margin-left: $size-val !important;
|
||||
margin-right: $size-val !important;
|
||||
}
|
||||
|
||||
// Y-axis (top and bottom)
|
||||
.py#{$breakpoint}-#{$size-key} {
|
||||
padding-top: $size-val !important;
|
||||
padding-bottom: $size-val !important;
|
||||
}
|
||||
.my#{$breakpoint}-#{$size-key} {
|
||||
margin-top: $size-val !important;
|
||||
margin-bottom: $size-val !important;
|
||||
}
|
||||
|
||||
.align-items-center#{$breakpoint} {
|
||||
align-items: center !important;
|
||||
}
|
||||
|
||||
.align-items-start#{$breakpoint} {
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Generate default utilities (without breakpoint modifier)
|
||||
@include generate-utilities("");
|
||||
|
||||
// 2. Generate utilities for each breakpoint using an @each loop
|
||||
@each $bp-name, $bp-min-width in $breakpoints {
|
||||
@media (min-width: $bp-min-width) {
|
||||
@include generate-utilities("-#{$bp-name}");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
@import 'utilities';
|
||||
|
||||
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
|
||||
|
||||
html, body {
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
background-color: #f5ffed !important;
|
||||
}
|
||||
|
||||
h1:focus {
|
||||
@@ -66,3 +69,7 @@ a, .btn-link {
|
||||
.blazor-error-boundary::after {
|
||||
content: "An error has occurred."
|
||||
}
|
||||
|
||||
.badge .badge-close {
|
||||
padding: 0 .3rem;
|
||||
}
|
||||
BIN
FoodsharingSiegen.Server/wwwroot/favicon-96x96.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 15 KiB |
1
FoodsharingSiegen.Server/wwwroot/favicon.svg
Normal file
|
After Width: | Height: | Size: 62 KiB |
21
FoodsharingSiegen.Server/wwwroot/site.webmanifest
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Foodsharing Einarbeitungen",
|
||||
"short_name": "FS Onboarding",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/web-app-manifest-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "/web-app-manifest-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
],
|
||||
"theme_color": "#e8ffe2",
|
||||
"background_color": "#f2ffe9",
|
||||
"display": "standalone"
|
||||
}
|
||||
BIN
FoodsharingSiegen.Server/wwwroot/web-app-manifest-192x192.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
FoodsharingSiegen.Server/wwwroot/web-app-manifest-512x512.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
@@ -45,6 +45,10 @@ namespace FoodsharingSiegen.Shared.Helper
|
||||
if (filter.DeletedOnly)
|
||||
filterListQ = filterListQ.Where(x => x.RecordState == RecordState.Archived);
|
||||
|
||||
// Show only prospects with possible IdCheck
|
||||
if (filter.IdCheckPossible)
|
||||
filterListQ = filterListQ.Where(x => x.Images != null && x.Images.Count > 0);
|
||||
|
||||
// No Activity Filter
|
||||
if (filter.NoActivity)
|
||||
filterListQ = filterListQ.Where(x => DateTime.Now - x.Modified > TimeSpan.FromDays(180));
|
||||
|
||||
27
FoodsharingSiegen.Tests/FoodsharingSiegen.Tests.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FoodsharingSiegen.Server\FoodsharingSiegen.Server.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
87
FoodsharingSiegen.Tests/LocalStorageServiceTests.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Text.Json;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using Microsoft.JSInterop;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace FoodsharingSiegen.Tests
|
||||
{
|
||||
public class LocalStorageServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetItem_ReturnsDeserializedObject_WhenItemExists()
|
||||
{
|
||||
// Arrange
|
||||
var mockJsRuntime = new Mock<IJSRuntime>();
|
||||
var service = new LocalStorageService(mockJsRuntime.Object);
|
||||
var expectedObject = new { Name = "Test" };
|
||||
var jsonString = JsonSerializer.Serialize(expectedObject);
|
||||
|
||||
mockJsRuntime.Setup(x => x.InvokeAsync<string>("localStorage.getItem", It.IsAny<object[]>()))
|
||||
.ReturnsAsync(jsonString);
|
||||
|
||||
// Act
|
||||
var result = await service.GetItem<dynamic>("testKey");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
mockJsRuntime.Verify(x => x.InvokeAsync<string>("localStorage.getItem", It.Is<object[]>(args => args.Length == 1 && args[0].ToString() == "testKey")), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetItem_ReturnsDefault_WhenItemDoesNotExist()
|
||||
{
|
||||
// Arrange
|
||||
var mockJsRuntime = new Mock<IJSRuntime>();
|
||||
var service = new LocalStorageService(mockJsRuntime.Object);
|
||||
|
||||
mockJsRuntime.Setup(x => x.InvokeAsync<string>("localStorage.getItem", It.IsAny<object[]>()))
|
||||
.ReturnsAsync((string?)null);
|
||||
|
||||
// Act
|
||||
var result = await service.GetItem<string>("testKey");
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetItem_CallsSetItemInLocalStorage()
|
||||
{
|
||||
// Arrange
|
||||
var mockJsRuntime = new Mock<IJSRuntime>();
|
||||
var service = new LocalStorageService(mockJsRuntime.Object);
|
||||
var objectToSave = new { Name = "Test" };
|
||||
var expectedJson = JsonSerializer.Serialize(objectToSave);
|
||||
|
||||
// Act
|
||||
await service.SetItem("testKey", objectToSave);
|
||||
|
||||
// Assert
|
||||
// Note: InvokeVoidAsync is an extension method that calls InvokeAsync<IJSVoidResult> under the hood in Blazor.
|
||||
mockJsRuntime.Verify(
|
||||
x => x.InvokeAsync<It.IsAnyType>(
|
||||
"localStorage.setItem",
|
||||
It.Is<object[]>(args => args.Length == 2 && args[0].ToString() == "testKey" && args[1].ToString() == expectedJson)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveItem_CallsRemoveItemInLocalStorage()
|
||||
{
|
||||
// Arrange
|
||||
var mockJsRuntime = new Mock<IJSRuntime>();
|
||||
var service = new LocalStorageService(mockJsRuntime.Object);
|
||||
|
||||
// Act
|
||||
await service.RemoveItem("testKey");
|
||||
|
||||
// Assert
|
||||
mockJsRuntime.Verify(
|
||||
x => x.InvokeAsync<It.IsAnyType>(
|
||||
"localStorage.removeItem",
|
||||
It.Is<object[]>(args => args.Length == 1 && args[0].ToString() == "testKey")),
|
||||
Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
FoodsharingSiegen.Tests/MailServiceTests.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace FoodsharingSiegen.Tests
|
||||
{
|
||||
public class MailServiceTests
|
||||
{
|
||||
private readonly Mock<IOptions<AppSettings>> _mockOptions;
|
||||
private readonly AppSettings _appSettings;
|
||||
private readonly Mock<ISmtpClient> _mockSmtpClient;
|
||||
|
||||
public MailServiceTests()
|
||||
{
|
||||
_appSettings = new AppSettings
|
||||
{
|
||||
Mail = new MailSettings
|
||||
{
|
||||
Host = "smtp.test.com",
|
||||
Port = 587,
|
||||
UseSsl = false,
|
||||
Username = "user@test.com",
|
||||
Password = "password123",
|
||||
FromAddress = "no-reply@test.com"
|
||||
},
|
||||
Terms = new TermSettings
|
||||
{
|
||||
Title = "Foodsharing Test"
|
||||
}
|
||||
};
|
||||
|
||||
_mockOptions = new Mock<IOptions<AppSettings>>();
|
||||
_mockOptions.Setup(o => o.Value).Returns(_appSettings);
|
||||
|
||||
_mockSmtpClient = new Mock<ISmtpClient>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendEmailAsync_ConnectsAuthenticatesAndSendsEmail()
|
||||
{
|
||||
// Arrange
|
||||
var service = new MailService(_mockOptions.Object, () => _mockSmtpClient.Object);
|
||||
var toEmail = "recipient@test.com";
|
||||
var subject = "Test Subject";
|
||||
var body = "<p>Test Body</p>";
|
||||
|
||||
// Act
|
||||
await service.SendEmailAsync(toEmail, subject, body);
|
||||
|
||||
// Assert
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.ConnectAsync(
|
||||
"smtp.test.com",
|
||||
587,
|
||||
SecureSocketOptions.Auto,
|
||||
It.IsAny<CancellationToken>()),
|
||||
Times.Once);
|
||||
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.AuthenticateAsync(
|
||||
"user@test.com",
|
||||
"password123",
|
||||
It.IsAny<CancellationToken>()),
|
||||
Times.Once);
|
||||
|
||||
// Verify a MimeMessage is passed to SendAsync with correct attributes
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.SendAsync(
|
||||
It.Is<MimeMessage>(m => m.Subject == subject),
|
||||
It.IsAny<CancellationToken>(),
|
||||
It.IsAny<MailKit.ITransferProgress>()),
|
||||
Times.Once);
|
||||
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.DisconnectAsync(
|
||||
true,
|
||||
It.IsAny<CancellationToken>()),
|
||||
Times.Once);
|
||||
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.Dispose(),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendEmailAsync_SkipsAuthentication_WhenUsernameIsBlank()
|
||||
{
|
||||
// Arrange
|
||||
_appSettings.Mail.Username = "";
|
||||
_appSettings.Mail.Password = "";
|
||||
var service = new MailService(_mockOptions.Object, () => _mockSmtpClient.Object);
|
||||
|
||||
// Act
|
||||
await service.SendEmailAsync("recipient@test.com", "Subject", "Body");
|
||||
|
||||
// Assert
|
||||
_mockSmtpClient.Verify(
|
||||
x => x.AuthenticateAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()),
|
||||
Times.Never);
|
||||
}
|
||||
}
|
||||
}
|
||||
236
FoodsharingSiegen.Tests/UserServiceTests.cs
Normal file
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Contracts.Enums;
|
||||
using FoodsharingSiegen.Contracts.Model;
|
||||
using FoodsharingSiegen.Server.Auth;
|
||||
using FoodsharingSiegen.Server.Data;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Service;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.JSInterop;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace FoodsharingSiegen.Tests
|
||||
{
|
||||
public class UserServiceTests
|
||||
{
|
||||
private FsContext CreateInMemoryContext(string dbName)
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<FsContext>()
|
||||
.UseInMemoryDatabase(databaseName: dbName)
|
||||
.Options;
|
||||
return new FsContext(options);
|
||||
}
|
||||
|
||||
private AuthService CreateAuthService(FsContext context, User? currentUser = null)
|
||||
{
|
||||
var mockJsRuntime = new Mock<IJSRuntime>();
|
||||
var localStorageService = new LocalStorageService(mockJsRuntime.Object);
|
||||
var authStateProvider = new Mock<AuthenticationStateProvider>();
|
||||
var mailService = new Mock<IMailService>();
|
||||
var appSettings = new Mock<IOptions<AppSettings>>();
|
||||
appSettings.Setup(x => x.Value).Returns(new AppSettings());
|
||||
|
||||
var authService = new AuthService(context, localStorageService, authStateProvider.Object, mailService.Object, appSettings.Object);
|
||||
|
||||
if (currentUser != null)
|
||||
{
|
||||
var field = typeof(AuthService).GetField("_user", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
field?.SetValue(authService, currentUser);
|
||||
}
|
||||
|
||||
return authService;
|
||||
}
|
||||
|
||||
private AuditService CreateAuditService(FsContext context, AuthService authService)
|
||||
{
|
||||
return new AuditService(context, authService);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddUserAsync_Fails_WhenEmailAlreadyExists()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
context.Users!.Add(new User { Mail = "existing@example.com", Name = "Existing", Password = "123" });
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.AddUserAsync(new User { Mail = "EXISTING@example.com", Name = "New" });
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.Equal("Diese E-Mail Adresse wird bereits verwendet", result.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddUserAsync_Succeeds_AndSetsPasswordEmpty_IfNull()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var newUser = new User { Mail = "new@example.com", Name = "New", };
|
||||
|
||||
var result = await userService.AddUserAsync(newUser);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.Equal(string.Empty, result.Data?.Password);
|
||||
Assert.NotNull(result.Data?.Created);
|
||||
Assert.Single(context.Users!);
|
||||
Assert.Single(context.Audits!);
|
||||
Assert.Equal(AuditType.CreateUser, context.Audits!.First().Type);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveAsync_TransferInteractions_AndRemovesUser()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
|
||||
var currentUser = new User { Id = Guid.NewGuid(), Mail = "current@example.com" };
|
||||
var authService = CreateAuthService(context, currentUser);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var userToRemove = new User { Id = Guid.NewGuid(), Mail = "remove@example.com", Type = UserType.User };
|
||||
context.Users!.Add(currentUser);
|
||||
context.Users!.Add(userToRemove);
|
||||
|
||||
context.Interactions!.Add(new Interaction { Id = Guid.NewGuid(), UserID = userToRemove.Id });
|
||||
context.Audits!.Add(new Audit { Id = Guid.NewGuid(), UserID = userToRemove.Id, Type = AuditType.None });
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.RemoveAsync(userToRemove.Id);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.Empty(context.Users!.Where(u => u.Id == userToRemove.Id));
|
||||
var interaction = context.Interactions!.First();
|
||||
Assert.Equal(currentUser.Id, interaction.UserID);
|
||||
Assert.Single(context.Audits!.Where(a => a.Type == AuditType.RemoveUser)); // created audit for remove
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveAsync_Fails_WhenLastAdmin()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var admin = new User { Id = Guid.NewGuid(), Mail = "admin@example.com", Type = UserType.Admin };
|
||||
context.Users!.Add(admin);
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.RemoveAsync(admin.Id);
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.Equal("Der letzte Administrator kann nicht gelöscht werden.", result.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetPassword_Fails_IfUserNotFound()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var result = await userService.SetPassword(new User { Id = Guid.NewGuid(), Password = "P" });
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.Equal("User not found", result.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetPassword_Succeeds()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var user = new User { Id = Guid.NewGuid(), Mail = "test@example.com", Password = "Old" };
|
||||
context.Users!.Add(user);
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.SetPassword(new User { Id = user.Id, Password = "New" });
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.Equal("New", context.Users!.First().Password);
|
||||
Assert.Equal(AuditType.SetUserPassword, context.Audits!.First().Type);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_Fails_IfNoChanges()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var user = new User { Id = Guid.NewGuid(), Mail = "a@a.com", Type = UserType.User };
|
||||
context.Users!.Add(user);
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.Update(new User { Id = user.Id, Mail = "a@a.com", Type = UserType.User });
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.Equal("Nichts zum Speichern gefunden", result.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_ForcesLogoutOnChange()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var user = new User { Id = Guid.NewGuid(), Mail = "a@a.com", Type = UserType.User };
|
||||
context.Users!.Add(user);
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.Update(new User { Id = user.Id, Mail = "b@b.com", Type = UserType.User });
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(context.Users!.First().ForceLogout);
|
||||
Assert.Single(context.Audits!.Where(a => a.Type == AuditType.UpdateUser));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_Fails_WhenDemotingLastAdmin()
|
||||
{
|
||||
var dbName = Guid.NewGuid().ToString();
|
||||
using var context = CreateInMemoryContext(dbName);
|
||||
var authService = CreateAuthService(context);
|
||||
var auditService = CreateAuditService(context, authService);
|
||||
var userService = new UserService(context, authService, auditService);
|
||||
|
||||
var admin = new User { Id = Guid.NewGuid(), Mail = "a@a.com", Type = UserType.Admin };
|
||||
context.Users!.Add(admin);
|
||||
context.SaveChanges();
|
||||
|
||||
var result = await userService.Update(new User { Id = admin.Id, Mail = "a@a.com", Type = UserType.User });
|
||||
|
||||
Assert.False(result.Success);
|
||||
Assert.Equal("Der Typ des letzten Administrators kann nicht geändert werden.", result.ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,68 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodsharingSiegen.Contracts
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodsharingSiegen.Shared", "FoodsharingSiegen.Shared\FoodsharingSiegen.Shared.csproj", "{625167D9-A375-40AF-82DE-87484519F6D9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodsharingSiegen.Tests", "FoodsharingSiegen.Tests\FoodsharingSiegen.Tests.csproj", "{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{63D6CC91-095D-44C3-8752-660DDF9C710C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F39AE3B4-E4CE-421E-AFB0-E9C9B3B670FE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{625167D9-A375-40AF-82DE-87484519F6D9}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A3BBF859-E3BB-420A-895F-B1BCF4B38B74}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||