Compare commits

...

27 Commits

Author SHA1 Message Date
troogs
19c22e6ae8 Refactor ProspectContainer and ProspectGrid: adjust layout styles and add grid class for improved responsiveness
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m32s
2026-04-21 05:48:55 +02:00
troogs
d1852f28c8 Remove target for adding generated CSS files to web assets
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m29s
2026-04-20 22:11:51 +02:00
troogs
e80d5b92f3 Add target to include generated CSS files in web assets
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m29s
2026-04-20 21:58:09 +02:00
troogs
62bfdb2023 Refactor VerificationSettingsDialog and UploadVerification: update modal title, adjust button styles, and enhance upload instructions 2026-04-20 21:45:40 +02:00
troogs
646ccb0f18 Add identity verification features: display image upload status and update UI elements
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m30s
2026-04-20 21:20:52 +02:00
troogs
ac52bc6df9 Remove unused CSS files for AuditView, DefaultLayout, NavMenu, and site 2026-04-20 20:24:52 +02:00
a.beging@eas-solutions.de
b3212acf6d Implement identity verification feature with image upload and token management
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 2m2s
2026-04-20 15:54:17 +02:00
a.beging@eas-solutions.de
a93de45270 Update .gitignore to exclude additional generated CSS files and add new utilities SCSS file 2026-04-20 15:43:32 +02:00
a.beging@eas-solutions.de
c7e0bfd8da Add interaction removal functionality and improve ProspectContainer layout
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m28s
2026-04-20 14:00:21 +02:00
a.beging@eas-solutions.de
5f5690e84d Update button label in Prospects page to include 'Neu' 2026-04-20 12:53:36 +02:00
a.beging@eas-solutions.de
05b74b929e Update .gitignore to exclude generated CSS files and appsettings.json 2026-04-20 12:47:37 +02:00
a.beging@eas-solutions.de
328e194611 Enhance ProspectContainer styling with improved CSS classes and layout adjustments 2026-04-20 12:47:02 +02:00
a.beging@eas-solutions.de
8a65c03c2c Update project configuration to replace LibSass with DartSass for improved styling capabilities 2026-04-20 11:35:44 +02:00
troogs
297a7c60bd Refactor prospect filtering and sorting components; remove obsolete ProspectFilterControl and enhance ProspectSortControl with filtering capabilities.
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m31s
2026-04-18 16:36:32 +02:00
troogs
8e5a37a0c9 Add password strength reminder to reset password page 2026-04-18 13:45:14 +02:00
troogs
ad6f28023e Implement password recovery feature with reset token and email notifications
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m28s
2026-04-18 13:36:21 +02:00
troogs
c5c24d44c9 Add GitHub Actions workflow for building and pushing development Docker image
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m47s
2026-04-18 12:41:38 +02:00
troogs
3687e573e0 Enhance login page with improved UI and error handling for invalid credentials 2026-04-18 01:57:31 +02:00
troogs
b7a7a8e078 Initialize TestMailReceiver with current user's email in Settings page 2026-04-18 01:46:25 +02:00
troogs
15780bccee Implement mail service with configuration and settings management 2026-04-18 01:43:52 +02:00
troogs
82d2c48ff7 Add launchUrl to project settings in launchSettings.json 2026-04-17 16:35:52 +02:00
troogs
41b1f8ae1d Update .gitignore to include buildinfo.txt and remove outdated app.db entry 2026-04-17 16:35:47 +02:00
troogs
eda6625e91 Add sorting functionality for prospects with new ProspectSortControl component 2026-04-16 21:42:15 +02:00
troogs
701388ee34 Implement sorting functionality for prospects with a dialog and custom sort options 2026-04-16 19:36:32 +02:00
troogs
3e099988bc Add ProspectSortOption enum and implement sorting dialog with buttons 2026-04-16 19:36:26 +02:00
troogs
ee967cd046 Enhance Prospect display in ProspectContainer.razor to show warning for missing name and format FsId 2026-04-16 16:59:04 +02:00
troogs
76c3e6ddde Refactor Button component in Prospects.razor for improved styling and structure 2026-04-16 16:57:39 +02:00
69 changed files with 2589 additions and 484 deletions

View File

@@ -0,0 +1,41 @@
name: Build And Push Dev Docker Image
on:
push:
branches:
- master
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
env:
DOTNET_ROLL_FORWARD: Major
REGISTRY: git.beging.de
BASE_IMAGE: git.beging.de/troogs/fs-onboarding-server
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.0.x"
- name: Publish server project
run: dotnet publish ./FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj -c Release -o ./Publish/Server
- name: Login to Gitea registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ env.REGISTRY }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build docker image
run: |
docker build \
-f ./Docker/dockerfile.server \
-t "${{ env.BASE_IMAGE }}:dev" \
.
- name: Push docker images
run: |
docker push "${{ env.BASE_IMAGE }}:dev"

View File

@@ -1,50 +0,0 @@
name: Build And Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag_name:
description: "Tag for the release (for example: v1.0.0)"
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.ref_name }}
DOTNET_ROLL_FORWARD: Major
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.0.x"
- name: Restore dependencies
run: dotnet restore FoodsharingSiegen.sln
- name: Publish server build
run: dotnet publish ./FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj -c Release -o ./artifacts/publish
- name: Create zip package
run: |
cd artifacts
zip -r FoodsharingSiegen.Server-${{ env.RELEASE_TAG }}.zip publish
- name: Create release and upload artifact
uses: https://gitea.com/actions/gitea-release-action@v1
with:
files: artifacts/FoodsharingSiegen.Server-${{ env.RELEASE_TAG }}.zip
tag_name: ${{ env.RELEASE_TAG }}
name: Release ${{ env.RELEASE_TAG }}
target_commitish: ${{ github.sha }}
token: ${{ github.token }}

10
.gitignore vendored
View File

@@ -6,3 +6,13 @@ riderModule.iml
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

7
Docker/.env Normal file
View File

@@ -0,0 +1,7 @@
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="FS Einarbeitungen Musterhausen"
MAIL_USE_SSL=true

View File

@@ -5,6 +5,17 @@ services:
image: ghcr.io/troogs/fs-onboarding/server:latest
ports:
- "8100:56000"
env_file:
- .env
environment:
# Mail Configuration Examples. These override options in appsettings.json.
# All values below can also be set via the active .env file or appsettings.json.
- Settings__Mail__Host=${MAIL_HOST:-smtp.example.com}
- Settings__Mail__Port=${MAIL_PORT:-587}
- Settings__Mail__Username=${MAIL_USERNAME:-your_username}
- Settings__Mail__Password=${MAIL_PASSWORD:-your_password}
- Settings__Mail__FromAddress=${MAIL_FROM_ADDRESS:-no-reply@example.com}
- Settings__Mail__UseSsl=${MAIL_USE_SSL:-true}
volumes:
- /docker/data/fs-onboarding/config:/app/config/
- /docker/data/fs-onboarding/data:/app/data/

View File

@@ -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
}
}

View 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; }
}
}

View File

@@ -95,6 +95,16 @@ namespace FoodsharingSiegen.Contracts.Entity
set => EncryptedPassword = Cryptor.Encrypt(value);
}
/// <summary>
/// Gets or sets the reset token for password recovery (ab)
/// </summary>
public string? ResetToken { get; set; }
/// <summary>
/// Gets or sets the expiry date for the reset token (ab)
/// </summary>
public DateTime? ResetTokenExpiry { get; set; }
/// <summary>
/// Gets or sets the value of the type (ab)
/// </summary>

View File

@@ -0,0 +1,10 @@
namespace FoodsharingSiegen.Contracts.Enums
{
public enum ProspectSortOption
{
NameAscending,
NameDescending,
ModifiedAscending,
ModifiedDescending
}
}

View File

@@ -6,6 +6,11 @@
public bool DisableStepIn { get; set; }
/// <summary>
/// Gets or sets the mail server settings.
/// </summary>
public MailSettings Mail { get; set; } = new();
public TermSettings Terms { get; set; } = new();
public bool TestMode { get; set; }

View File

@@ -0,0 +1,38 @@
namespace FoodsharingSiegen.Contracts.Model
{
/// <summary>
/// Configuration settings for the mail service.
/// </summary>
public class MailSettings
{
/// <summary>
/// Gets or sets the SMTP server host.
/// </summary>
public string Host { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the SMTP port.
/// </summary>
public int Port { get; set; } = 587;
/// <summary>
/// Gets or sets the username for SMTP authentication.
/// </summary>
public string Username { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the password for SMTP authentication.
/// </summary>
public string Password { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the sender address.
/// </summary>
public string FromAddress { get; set; } = string.Empty;
/// <summary>
/// Gets or sets whether to use SSL/TLS connection.
/// </summary>
public bool UseSsl { get; set; } = true;
}
}

View File

@@ -12,6 +12,26 @@ namespace FoodsharingSiegen.Contracts
/// </summary>
public const string ProspectFilter = "ProspectFilter";
/// <summary>
/// Represents the storage key used for prospect sorting preferences.
/// </summary>
public const string SortProspects = "SortProspects";
/// <summary>
/// Represents the storage key used for sorting all prospects.
/// </summary>
public const string SortProspectsAll = "SortProspectsAll";
/// <summary>
/// Represents the storage key used for sorting completed prospects.
/// </summary>
public const string SortProspectsDone = "SortProspectsDone";
/// <summary>
/// Represents the storage key used for sorting prospects pending verification.
/// </summary>
public const string SortProspectsVerify = "SortProspectsVerify";
/// <summary>
/// The token key
/// </summary>

View File

@@ -50,6 +50,11 @@ namespace FoodsharingSiegen.Server.Auth
/// </summary>
private User? _user;
/// <summary>
/// The mail service
/// </summary>
private readonly IMailService _mailService;
#endregion
#region Setup/Teardown
@@ -60,14 +65,17 @@ namespace FoodsharingSiegen.Server.Auth
/// <param name="context">The context</param>
/// <param name="localStorageService">The local storage service</param>
/// <param name="authenticationStateProvider">The authentication state provider</param>
/// <param name="mailService">The mail service</param>
public AuthService(
FsContext context,
LocalStorageService localStorageService,
AuthenticationStateProvider authenticationStateProvider)
AuthenticationStateProvider authenticationStateProvider,
IMailService mailService)
{
Context = context;
_localStorageService = localStorageService;
_authenticationStateProvider = authenticationStateProvider;
_mailService = mailService;
}
#endregion
@@ -186,5 +194,52 @@ namespace FoodsharingSiegen.Server.Auth
}
#endregion
#region Password Recovery
public async Task InitiatePasswordReset(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.AddMinutes(30);
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";
await _mailService.SendEmailAsync(user.Mail, "Passwort zurücksetzen", mailBody);
}
public async Task<OperationResult> ResetPassword(string token, string newPassword)
{
if (string.IsNullOrWhiteSpace(token)) return new OperationResult(new Exception("Ungültiges Token."));
if (string.IsNullOrWhiteSpace(newPassword)) return new OperationResult(new Exception("Passwort darf nicht leer sein."));
var user = await Context.Users!.FirstOrDefaultAsync(x => x.ResetToken == token && x.ResetTokenExpiry > DateTime.UtcNow);
if (user == null) return new OperationResult(new Exception("Token ist ungültig oder abgelaufen."));
user.Password = newPassword;
user.ResetToken = null;
user.ResetTokenExpiry = null;
await Context.SaveChangesAsync();
return new OperationResult();
}
public async Task<bool> IsResetTokenValid(string token)
{
if (string.IsNullOrWhiteSpace(token)) return false;
var user = await Context.Users!.FirstOrDefaultAsync(x => x.ResetToken == token && x.ResetTokenExpiry > DateTime.UtcNow);
return user != null;
}
#endregion
}
}

View File

@@ -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,28 +12,32 @@
<div class="@divClass">
<h5 class="mb-2 d-flex">
<div class="flex-grow-1">
@Prospect?.Name
<small style="font-size: .9rem;">@Prospect?.FsId</small>
</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)
<div class="flex-grow-1 d-flex">
<div>
@if(string.IsNullOrWhiteSpace(Prospect?.Name))
{
<i class="fa-solid fa-box-archive link ml-2" @onclick="ArchiveProspectAsync" title="Archivieren" @onclick:preventDefault></i>
<i class="fa-solid fa-exclamation-triangle text-warning"></i>
<doublearrows></doublearrows>
<em>»Name fehlt«</em>
}
else
{
<i class="fa-solid fa-recycle link ml-2" @onclick="RestoreProspectAsync" title="Wiederherstellen" @onclick:preventDefault></i>
@Prospect?.Name
}
</div>
<div style="flex-grow: 1;"></div>
@if (Prospect?.FsId != null && Prospect.FsId != 0)
{
<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>
</h5>
@@ -58,6 +63,12 @@
IconClass="fa-solid fa-handshake-simple">
</InteractionRow>
<tr>
<td colspan="3">
<hr style="margin: 10px 0;">
</td>
</tr>
@if (!AppSettings.DisableStepIn)
{
<InteractionRow
@@ -133,27 +144,86 @@
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 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;">Perso-Check 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)
{
@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)"
><i class="fa-solid fa-flag"></i>
</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>

View File

@@ -87,6 +87,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 +116,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

View File

@@ -16,13 +16,18 @@
.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;
height: 100%;
width: 100%;
max-width: none;
border-radius: 12px;
margin: 0;
padding: 1rem 1rem 0 1rem;
}
@media (max-width: 576px) {
.pc-main {
padding: .5rem .5rem 0 .5rem;
}
}
.pc-main.warning {

View File

@@ -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 (&lt; 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 (&gt; 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>

View File

@@ -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"

View File

@@ -0,0 +1,12 @@
.prospect-grid {
/* Default card width range. Override via a modifier class on ProspectGrid. */
--pc-min-width: 200px;
--pc-max-width: 350px;
display: grid;
gap: 1rem;
width: 100%;
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--pc-min-width)), var(--pc-max-width)));
justify-content: center;
align-items: stretch;
}

View File

@@ -0,0 +1,52 @@
@using FoodsharingSiegen.Contracts.Enums
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
<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 Color="Color.Primary"
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" />
</div>
<div class="badge-row mt-1 mb-3">
@if (HasCustomSort)
{
<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>
}
</div>

View File

@@ -0,0 +1,112 @@
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;
using Microsoft.AspNetCore.Components;
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;
[Parameter]
public EventCallback<ProspectSortOption> CurrentSortChanged { get; set; }
[Parameter]
public EventCallback OnSortChanged { get; set; }
[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))
{
var savedSort = await LocalStorageService.GetItem<ProspectSortOption?>(StorageKey);
if (savedSort.HasValue)
{
CurrentSort = savedSort.Value;
await CurrentSortChanged.InvokeAsync(CurrentSort);
}
}
await base.OnInitializedAsync();
}
private async Task OpenSortDialogAsync()
{
await ProspectSortDialog.ShowAsync(ModalService, CurrentSort, async option =>
{
await UpdateSortAsync(option);
});
}
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;
}
await FilterChanged.InvokeAsync(Filter);
}
private bool HasCustomSort => CurrentSort != ProspectSortOption.NameAscending;
private string CurrentSortText => CurrentSort switch
{
ProspectSortOption.NameDescending => "Sortierung: Name (absteigend)",
ProspectSortOption.ModifiedAscending => "Sortierung: Zuletzt geändert (aufsteigend)",
ProspectSortOption.ModifiedDescending => "Sortierung: Zuletzt geaendert (absteigend)",
_ => string.Empty
};
private async Task ResetSortAsync()
{
await UpdateSortAsync(ProspectSortOption.NameAscending);
}
private async Task UpdateSortAsync(ProspectSortOption option)
{
CurrentSort = option;
if (!string.IsNullOrEmpty(StorageKey))
{
await LocalStorageService.SetItem(StorageKey, CurrentSort);
}
await CurrentSortChanged.InvokeAsync(CurrentSort);
await OnSortChanged.InvokeAsync();
}
}

View File

@@ -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>

View File

@@ -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,139 @@ 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();
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();
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 Context.SaveChangesAsync();
}
return new();
}
catch (Exception e)
{
return new(e);
}
}
#endregion
}
}

View File

@@ -0,0 +1,49 @@
@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.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 (&lt; 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 (&gt; 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>

View File

@@ -0,0 +1,51 @@
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
};
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();
}
}
}

View File

@@ -0,0 +1,9 @@
@inherits FsBase
@using FoodsharingSiegen.Contracts.Enums
<div class="d-grid gap-2">
<Button Color="@GetSortButtonColor(ProspectSortOption.NameAscending)" Clicked="() => SelectAsync(ProspectSortOption.NameAscending)">Name (aufsteigend)</Button>
<Button Color="@GetSortButtonColor(ProspectSortOption.NameDescending)" Clicked="() => SelectAsync(ProspectSortOption.NameDescending)">Name (absteigend)</Button>
<Button Color="@GetSortButtonColor(ProspectSortOption.ModifiedAscending)" Clicked="() => SelectAsync(ProspectSortOption.ModifiedAscending)">Geändert (aufsteigend)</Button>
<Button Color="@GetSortButtonColor(ProspectSortOption.ModifiedDescending)" Clicked="() => SelectAsync(ProspectSortOption.ModifiedDescending)">Geändert (absteigend)</Button>
</div>

View File

@@ -0,0 +1,39 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Server.BaseClasses;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Dialogs
{
public partial class ProspectSortDialog : FsBase
{
[Parameter]
public ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
[Parameter]
public Func<ProspectSortOption, Task>? OnSortSelected { get; set; }
public static async Task ShowAsync(IModalService modalService, ProspectSortOption currentSort, Func<ProspectSortOption, Task> onSortSelected)
{
await modalService.Show<ProspectSortDialog>("Sortieren", p =>
{
p.Add(nameof(CurrentSort), currentSort);
p.Add(nameof(OnSortSelected), onSortSelected);
}, new ModalInstanceOptions
{
Size = ModalSize.Small,
});
}
private Color GetSortButtonColor(ProspectSortOption option)
{
return CurrentSort == option ? Color.Success : Color.Secondary;
}
private async Task SelectAsync(ProspectSortOption option)
{
if (OnSortSelected != null) await OnSortSelected(option);
await ModalService.Hide();
}
}
}

View File

@@ -0,0 +1,34 @@
@using Blazorise
@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 /><br />
<Button Color="Color.Secondary" Clicked="CopyLink" Style="width: 100%;">
<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>
<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>

View File

@@ -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 NavigationManager NavigationManager { 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 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);
}
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 dieses Users unwiderruflich gelöscht werden?", async () =>
{
var result = await ProspectService.DeleteVerificationImagesAsync(Prospect.Id);
if (result.Success)
{
ImageCount = 0;
if(OnDataChanged != null) await OnDataChanged();
}
});
}
}
}

View File

@@ -0,0 +1,44 @@
@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>
<img src="@(_images[SelectedImageIndex.Value])" class="img-fluid rounded" style="max-height: 80vh;" />
<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>
}

View 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 });
}
}
}

View File

@@ -22,13 +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="DartSassBuilder" Version="1.1.0" />
<PackageReference Include="MailKit" Version="4.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PrivateAssets>all</PrivateAssets>

View File

@@ -0,0 +1,223 @@
// <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("20260418111848_PasswordRecovery")]
partial class PasswordRecovery
{
/// <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<bool>("Warning")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Prospects");
});
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.Prospect", b =>
{
b.Navigation("Interactions");
});
modelBuilder.Entity("FoodsharingSiegen.Contracts.Entity.User", b =>
{
b.Navigation("Interactions");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FoodsharingSiegen.Server.Migrations
{
/// <inheritdoc />
public partial class PasswordRecovery : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ResetToken",
table: "Users",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "ResetTokenExpiry",
table: "Users",
type: "TEXT",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ResetToken",
table: "Users");
migrationBuilder.DropColumn(
name: "ResetTokenExpiry",
table: "Users");
}
}
}

View 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
}
}
}

View File

@@ -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");
}
}
}

View File

@@ -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")
@@ -160,6 +191,12 @@ namespace FoodsharingSiegen.Server.Migrations
b.Property<int>("Network")
.HasColumnType("INTEGER");
b.Property<string>("ResetToken")
.HasColumnType("TEXT");
b.Property<DateTime?>("ResetTokenExpiry")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
@@ -199,8 +236,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");
});

View File

@@ -1,3 +0,0 @@
.p-audit > ::deep form {
height: calc(100% - 68px);
}

View File

@@ -0,0 +1,54 @@
@page "/forgot-password"
@using FoodsharingSiegen.Shared.Helper
@layout LoginLayout
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
<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="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>
<p class="text-muted">Passwort zurücksetzen</p>
</div>
@if (IsSubmitted)
{
<div class="alert alert-success text-center">
Wenn ein Benutzerkonto mit dieser E-Mail-Adresse existiert, wurde eine E-Mail mit weiteren Anweisungen versendet.
</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>
</div>
}
else
{
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
<Field>
<FieldLabel>E-Mail Adresse</FieldLabel>
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" KeyUp="TextEdit_KeyUp" Size="Size.Large"></TextEdit>
</Field>
</Validation>
<Button Class="mt-4 w-100" Color="Color.Primary" Size="Size.Large" Clicked="SubmitRequest" Disabled="@(IsValidMail != ValidationStatus.Success || IsLoading)">
@if (IsLoading)
{
<i class="fas fa-spinner fa-spin mr-2"></i> <span>Wird gesendet...</span>
}
else
{
<i class="fas fa-paper-plane mr-2"></i> <span>Passwort zurücksetzen</span>
}
</Button>
<div class="text-center mt-3">
<a href="/login" style="font-size: 0.85rem; color: #64ae24; text-decoration: none;"><i class="fas fa-arrow-left mr-1"></i> Zurück zum Login</a>
</div>
}
</div>
</div>
</div>

View File

@@ -0,0 +1,41 @@
using Blazorise;
using FoodsharingSiegen.Server.BaseClasses;
using FoodsharingSiegen.Server.Auth;
using FoodsharingSiegen.Shared.Helper;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System.Threading.Tasks;
namespace FoodsharingSiegen.Server.Pages
{
public partial class ForgotPassword : FsBase
{
public string MailAddress { get; set; } = string.Empty;
public ValidationStatus IsValidMail { get; set; } = ValidationStatus.None;
public bool IsSubmitted { get; set; }
public bool IsLoading { get; set; }
public async Task SubmitRequest()
{
if (IsValidMail != ValidationStatus.Success) return;
IsLoading = true;
await InvokeAsync(StateHasChanged);
await AuthService.InitiatePasswordReset(MailAddress, NavigationManager.BaseUri);
IsSubmitted = true;
IsLoading = false;
await InvokeAsync(StateHasChanged);
}
public async Task TextEdit_KeyUp(KeyboardEventArgs e)
{
if (e.Key == "Enter" && IsValidMail == ValidationStatus.Success)
{
await SubmitRequest();
}
}
}
}

View File

@@ -4,24 +4,45 @@
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
<PageTitle>@AppSettings.Terms.Title</PageTitle>
<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="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>
<p class="text-muted">Bitte melde dich an, um fortzufahren.</p>
</div>
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
<div class="card" style="width: 100%; max-width: 380px;">
<div class="card-header">@AppSettings.Terms.Title</div>
<div class="card-body">
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
<Field>
<FieldLabel>E-Mail Adresse</FieldLabel>
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" KeyUp="TextEdit_KeyUp" Size="Size.Large"></TextEdit>
</Field>
</Validation>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">
<TextEdit @bind-Text="Password" Role="TextRole.Password" Placeholder="Passwort" Class="my-3" KeyUp="TextEdit_KeyUp"></TextEdit>
<Field Class="mt-3">
<FieldLabel>Passwort</FieldLabel>
<TextEdit @bind-Text="Password" Role="TextRole.Password" Placeholder="Passwort" KeyUp="TextEdit_KeyUp" Size="Size.Large"></TextEdit>
</Field>
</Validation>
<div class="d-flex justify-content-center">
<Button Clicked="PerformLogin" Disabled="@(IsValidMail != ValidationStatus.Success || IsValidPassword != ValidationStatus.Success)">Einloggen</Button>
</div>
@if (!string.IsNullOrEmpty(LoginErrorMessage))
{
<div class="text-danger mt-3 text-center">
<i class="fas fa-exclamation-triangle mr-1"></i> @LoginErrorMessage
</div>
}
<Button Class="mt-4 w-100" Color="Color.Primary" Size="Size.Large" Clicked="PerformLogin" Disabled="@(IsValidMail != ValidationStatus.Success || IsValidPassword != ValidationStatus.Success)">
<i class="fas fa-sign-in-alt mr-2"></i> Einloggen
</Button>
<div class="d-flex justify-content-center align-items-center mt-2">
<a href="/forgot-password" tabindex="-1" style="font-size: 0.85rem; color: #64ae24; text-decoration: none;">Passwort vergessen?</a>
</div>
</div>
</div>
</div>

View File

@@ -33,6 +33,11 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private string? Password { get; set; }
/// <summary>
/// Gets or sets the login error message
/// </summary>
private string? LoginErrorMessage { get; set; }
#endregion
#region Private Method PerformLogin
@@ -42,12 +47,14 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private async Task PerformLogin()
{
LoginErrorMessage = null;
//Todo Eingaben Validieren [04.04.22 - Andre Beging]
if (string.IsNullOrWhiteSpace(MailAddress) || string.IsNullOrWhiteSpace(Password))
{
MailAddress = string.Empty;
Password = string.Empty;
LoginErrorMessage = "E-Mail-Adresse oder Passwort ist ungültig.";
return;
}
@@ -55,7 +62,7 @@ namespace FoodsharingSiegen.Server.Pages
if (loginR.Success)
NavigationManager.NavigateTo("/", true);
else
await Notification.Error(loginR.ErrorMessage)!;
LoginErrorMessage = "E-Mail-Adresse oder Passwort ist ungültig.";
}
#endregion

View File

@@ -2,6 +2,7 @@
@page "/prospect"
@page "/prospects"
@using FoodsharingSiegen.Contracts
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@@ -16,20 +17,25 @@
<Button
Color="Color.Primary"
Height="Height.Px(50)"
title="Hinzufügen"
style="min-width: auto;"
Clicked="@CreateProspectAsync"
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
>Hinzufügen
><i class="fa-solid fa-plus"></i> Neu
</Button>
|
<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="filterList"
Prospects="sortList"
OnDataChanged="@LoadProspects"
StateFilter="ProspectStateFilter.OnBoarding">
</ProspectGrid>

View File

@@ -36,6 +36,8 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private List<Prospect>? ProspectList { get; set; }
private ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
#endregion
#region Override InitializeDataAsync

View File

@@ -1,6 +1,7 @@
@page "/all"
@page "/archive"
@using FoodsharingSiegen.Contracts
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@@ -13,15 +14,15 @@
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
}
<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="filterList"
Prospects="sortList"
OnDataChanged="@LoadProspects"
StateFilter="ProspectStateFilter.All">
</ProspectGrid>

View File

@@ -39,6 +39,8 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private List<Prospect>? ProspectList { get; set; }
private ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
#endregion
#region Override InitializeDataAsync

View File

@@ -1,5 +1,6 @@
@page "/done"
@using FoodsharingSiegen.Contracts
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@@ -12,15 +13,15 @@
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
}
<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="filterList"
Prospects="sortList"
OnDataChanged="@LoadProspects"
StateFilter="ProspectStateFilter.Completed">
</ProspectGrid>

View File

@@ -31,6 +31,8 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private List<Prospect>? ProspectList { get; set; }
private ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
#endregion
#region Override InitializeDataAsync

View File

@@ -1,5 +1,6 @@
@page "/verify"
@using FoodsharingSiegen.Contracts
@using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper
@inherits FsBase
@@ -12,15 +13,16 @@
<div class="alert alert-danger"><strong>TESTMODUS!</strong> Änderungen werden wieder gelöscht.</div>
}
<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="filterList"
Prospects="sortList"
OnDataChanged="@LoadProspects"
StateFilter="ProspectStateFilter.Verification">
</ProspectGrid>

View File

@@ -37,6 +37,8 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private List<Prospect>? ProspectList { get; set; }
private ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending;
#endregion
#region Override InitializeDataAsync

View File

@@ -0,0 +1,86 @@
@page "/reset-password/{Token}"
@using FoodsharingSiegen.Shared.Helper
@layout LoginLayout
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
<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="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>
<p class="text-muted">Neues Passwort festlegen</p>
</div>
@if (IsInitializing)
{
<div class="text-center mt-4">
<i class="fas fa-spinner fa-spin fa-2x mb-3" style="color: #64ae24;"></i>
<p>Token wird überprüft...</p>
</div>
}
else if (!IsTokenValid)
{
<div class="alert alert-danger text-center">
<i class="fas fa-exclamation-triangle fa-2x mb-2 d-block"></i>
Der Link zum Zurücksetzen des Passworts ist ungültig oder abgelaufen. Bitte fordere einen neuen an.
</div>
<div class="text-center mt-4">
<a href="/forgot-password" class="btn btn-outline-primary w-100 mb-2"><i class="fas fa-redo mr-2"></i> Neuen Link anfordern</a>
<a href="/login" class="btn btn-link w-100" style="color: #64ae24;">Zurück zum Login</a>
</div>
}
else if (IsSuccess)
{
<div class="alert alert-success text-center">
Passwort erfolgreich aktualisiert. Du kannst dich jetzt anmelden.
</div>
<div class="text-center mt-4">
<a href="/login" class="btn btn-outline-primary"><i class="fas fa-sign-in-alt mr-2"></i> Zum Login</a>
</div>
}
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>
<TextEdit @bind-Text="NewPassword" Role="TextRole.Password" Placeholder="Passwort (min. 8 Zeichen, min. 1 Zahl)" KeyUp="TextEdit_KeyUp" Size="Size.Large"></TextEdit>
</Field>
</Validation>
<Validation Validator="ValidatePasswordConfirmation" @bind-Status="@IsValidPasswordConfirmation">
<Field Class="mt-3">
<FieldLabel>Passwort bestätigen</FieldLabel>
<TextEdit @bind-Text="ConfirmPassword" Role="TextRole.Password" Placeholder="Passwort bestätigen" KeyUp="TextEdit_KeyUp" Size="Size.Large"></TextEdit>
</Field>
</Validation>
@if (!string.IsNullOrEmpty(ErrorMessage))
{
<div class="text-danger mt-3 text-center">
<i class="fas fa-exclamation-triangle mr-1"></i> @ErrorMessage
</div>
}
<Button Class="mt-4 w-100" Color="Color.Primary" Size="Size.Large" Clicked="SubmitReset" Disabled="@(IsValidPassword != ValidationStatus.Success || IsValidPasswordConfirmation != ValidationStatus.Success || IsLoading)">
@if (IsLoading)
{
<i class="fas fa-spinner fa-spin mr-2"></i> <span>Speichern...</span>
}
else
{
<i class="fas fa-save mr-2"></i> <span>Passwort speichern</span>
}
</Button>
}
</div>
</div>
</div>

View File

@@ -0,0 +1,77 @@
using Blazorise;
using FoodsharingSiegen.Server.BaseClasses;
using FoodsharingSiegen.Server.Auth;
using FoodsharingSiegen.Shared.Helper;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System.Threading.Tasks;
namespace FoodsharingSiegen.Server.Pages
{
public partial class ResetPassword : FsBase
{
[Parameter]
public string Token { get; set; } = string.Empty;
public string NewPassword { get; set; } = string.Empty;
public string ConfirmPassword { get; set; } = string.Empty;
public ValidationStatus IsValidPassword { get; set; } = ValidationStatus.None;
public ValidationStatus IsValidPasswordConfirmation { get; set; } = ValidationStatus.None;
public string ErrorMessage { get; set; } = string.Empty;
public bool IsSuccess { get; set; }
public bool IsLoading { get; set; }
public bool IsInitializing { get; set; } = true;
public bool IsTokenValid { get; set; }
protected override async Task OnInitializedAsync()
{
IsTokenValid = await AuthService.IsResetTokenValid(Token);
IsInitializing = false;
}
public void ValidatePasswordConfirmation(ValidatorEventArgs args)
{
var confirmPassword = System.Convert.ToString(args.Value);
if (string.IsNullOrWhiteSpace(confirmPassword))
{
args.Status = ValidationStatus.None;
return;
}
args.Status = confirmPassword == NewPassword ? ValidationStatus.Success : ValidationStatus.Error;
}
public async Task SubmitReset()
{
if (IsValidPassword != ValidationStatus.Success || IsValidPasswordConfirmation != ValidationStatus.Success) return;
IsLoading = true;
ErrorMessage = string.Empty;
await InvokeAsync(StateHasChanged);
var result = await AuthService.ResetPassword(Token, NewPassword);
if (result.Success)
{
IsSuccess = true;
}
else
{
ErrorMessage = result.Exception?.Message ?? "Ein Fehler ist aufgetreten.";
}
IsLoading = false;
await InvokeAsync(StateHasChanged);
}
public async Task TextEdit_KeyUp(KeyboardEventArgs e)
{
if (e.Key == "Enter" && IsValidPassword == ValidationStatus.Success && IsValidPasswordConfirmation == ValidationStatus.Success)
{
await SubmitReset();
}
}
}
}

View File

@@ -0,0 +1,30 @@
@page "/settings"
@inherits FsBase
<PageTitle>Einstellungen - @AppSettings.Terms.Title</PageTitle>
<div style="width: 100%; max-width: 500px;">
<h2>Einstellungen</h2>
<div class="card mt-3">
<div class="card-header" style="padding: .5rem 0 0 1rem;"><h5>Mail Service</h5></div>
<div class="card-body">
<p>
<strong>SMTP Server:</strong> @AppSettings.Mail.Host<br />
<strong>Port:</strong> @AppSettings.Mail.Port<br />
<strong>SSL:</strong> @(AppSettings.Mail.UseSsl ? "Ja" : "Nein")<br />
</p>
<hr />
<Fields Class="my-3">
<Field ColumnSize="ColumnSize.Is12">
<FieldLabel>Testmail-Empfänger</FieldLabel>
<FieldBody>
<TextEdit @bind-Text="TestMailReceiver" Placeholder="E-Mail Adresse"></TextEdit>
</FieldBody>
</Field>
</Fields>
<Button Color="Color.Primary" Clicked="SendTestMail">Testmail senden</Button>
</div>
</div>
</div>

View File

@@ -0,0 +1,46 @@
using FoodsharingSiegen.Contracts.Helper;
using FoodsharingSiegen.Server.Service;
using Microsoft.AspNetCore.Components;
using System;
using System.Threading.Tasks;
namespace FoodsharingSiegen.Server.Pages
{
public partial class Settings
{
[Inject]
public IMailService MailService { get; set; } = null!;
private string TestMailReceiver { get; set; } = string.Empty;
protected override async Task InitializeDataAsync()
{
if (!CurrentUser.IsAdmin())
{
NavigationManager.NavigateTo("/");
return;
}
TestMailReceiver = CurrentUser.Mail ?? string.Empty;
await Task.CompletedTask;
}
private async Task SendTestMail()
{
if (string.IsNullOrWhiteSpace(TestMailReceiver))
{
await Notification.Error("Bitte eine Empfänger-Adresse angeben.");
return;
}
try
{
await MailService.SendEmailAsync(TestMailReceiver, "Testmail", "Dies ist eine Testmail.");
await Notification.Success("Testmail versendet.");
}
catch (Exception ex)
{
await Notification.Error($"Fehler beim Senden: {ex.Message}");
}
}
}
}

View File

@@ -0,0 +1,106 @@
@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 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-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>
<div class="mb-4 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
{
<span class="badge bg-secondary mb-2 text-wrap">Es können noch bis zu @(5 - _uploadedCount) Bilder hochgeladen werden</span>
<InputFile id="fileInput" OnChange="OnInputFileChange" class="d-none" accept="image/*" />
<label for="fileInput" class="btn btn-outline-success w-100">
<i class="fa-solid fa-images me-2"></i>Bild auswählen
</label>
}
</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>
}
@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>
}
}
</div>
</div>
</div>
</div>

View 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();
}
}
}

View File

@@ -29,6 +29,7 @@ builder.Services.AddScoped<AuditService>();
builder.Services.AddScoped<AuthService>();
builder.Services.AddScoped<UserService>();
builder.Services.AddScoped<ProspectService>();
builder.Services.AddScoped<IMailService, MailService>();
builder.Services
.AddBlazorise()

View File

@@ -12,6 +12,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "http://localhost:56000/",
"applicationUrl": "http://localhost:56000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"

View File

@@ -0,0 +1,19 @@
using System.Threading.Tasks;
namespace FoodsharingSiegen.Server.Service
{
/// <summary>
/// Service interface for sending emails.
/// </summary>
public interface IMailService
{
/// <summary>
/// Sends an email asynchronously.
/// </summary>
/// <param name="toEmail">The recipient's email address.</param>
/// <param name="subject">The subject of the email.</param>
/// <param name="htmlBody">The HTML content of the email body.</param>
/// <returns>A task that represents the asynchronous email sending operation.</returns>
Task SendEmailAsync(string toEmail, string subject, string htmlBody);
}
}

View File

@@ -0,0 +1,57 @@
using System.Threading.Tasks;
using FoodsharingSiegen.Contracts.Model;
using MailKit.Net.Smtp;
using MailKit.Security;
using Microsoft.Extensions.Options;
using MimeKit;
using MimeKit.Text;
namespace FoodsharingSiegen.Server.Service
{
/// <summary>
/// Default implementation of <see cref="IMailService"/> which sends emails via SMTP using MailKit.
/// </summary>
public class MailService : IMailService
{
private readonly MailSettings _mailSettings;
private readonly TermSettings _termSettings;
/// <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)
{
_mailSettings = appSettings.Value.Mail;
_termSettings = appSettings.Value.Terms;
}
/// <inheritdoc/>
public async Task SendEmailAsync(string toEmail, string subject, string htmlBody)
{
var email = new MimeMessage();
email.From.Add(new MailboxAddress(_termSettings.Title, _mailSettings.FromAddress));
email.To.Add(MailboxAddress.Parse(toEmail));
email.Subject = subject;
var textPart = new TextPart(TextFormat.Html)
{
Text = htmlBody
};
email.Body = textPart;
using var smtp = new SmtpClient();
var secureOptions = _mailSettings.UseSsl ? SecureSocketOptions.StartTls : SecureSocketOptions.Auto;
await smtp.ConnectAsync(_mailSettings.Host, _mailSettings.Port, secureOptions);
if (!string.IsNullOrWhiteSpace(_mailSettings.Username))
{
await smtp.AuthenticateAsync(_mailSettings.Username, _mailSettings.Password);
}
await smtp.SendAsync(email);
await smtp.DisconnectAsync(true);
}
}
}

View File

@@ -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;
}
}

View File

@@ -49,13 +49,21 @@
@if (CurrentUser.IsAdmin())
{
<div class="nav-item px-3 pb-0">
<div class="nav-item px-3">
<div @onclick="NavLinkClickedAsync">
<NavLink class="nav-link" href="users" Match="NavLinkMatch.All">
<span class="fas fa-users mr-2" aria-hidden="true" style="font-size: 1.4em;"></span> Benutzer
</NavLink>
</div>
</div>
<div class="nav-item px-3 pb-0">
<div @onclick="NavLinkClickedAsync">
<NavLink class="nav-link" href="settings" Match="NavLinkMatch.All">
<span class="fas fa-cog mr-2" aria-hidden="true" style="font-size: 1.4em;"></span> Einstellungen
</NavLink>
</div>
</div>
}
<div class="nav-item px-3">

View File

@@ -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;
}

View File

@@ -1,4 +1,4 @@
{
{
"Kestrel": {
"Endpoints": {
"Http": {
@@ -9,10 +9,18 @@
"DetailedErrors": true,
"Settings": {
"TestMode": true,
"Mail": {
"Host": "mail.example.com",
"Port": 587,
"Username": "your_username",
"Password": "your_password",
"FromAddress": "no-reply@example.com",
"UseSsl": true
},
"Terms": {
"Title": "Foodsharing Musterhausen",
"TitleShort": "Musterhausen",
"StepInName": "Krabbelgruppe2"
"StepInName": "Neulingstreffen"
}
}
}

View File

@@ -1 +0,0 @@
20260410

View File

@@ -0,0 +1,72 @@
// 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;
}
}
}
// 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}");
}
}

View File

@@ -1,3 +1,5 @@
@import 'utilities';
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
html, body {
@@ -66,3 +68,4 @@ a, .btn-link {
.blazor-error-boundary::after {
content: "An error has occurred."
}

View File

@@ -56,6 +56,20 @@ namespace FoodsharingSiegen.Shared.Helper
return filterListQ.ToList();
}
public static List<Prospect> ApplySort(this List<Prospect>? prospectList, ProspectSortOption sortOption)
{
if (prospectList == null) return [];
return sortOption switch
{
ProspectSortOption.NameAscending => prospectList.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase).ToList(),
ProspectSortOption.NameDescending => prospectList.OrderByDescending(x => x.Name, StringComparer.OrdinalIgnoreCase).ToList(),
ProspectSortOption.ModifiedAscending => prospectList.OrderBy(x => x.Modified ?? x.Created).ToList(),
ProspectSortOption.ModifiedDescending => prospectList.OrderByDescending(x => x.Modified ?? x.Created).ToList(),
_ => prospectList
};
}
#endregion
}
}

View File

@@ -46,7 +46,7 @@ namespace FoodsharingSiegen.Shared.Helper
return;
}
var isValid = password.Length > 3;
var isValid = password.Length >= 8 && password.Any(char.IsDigit);
args.Status = isValid ? ValidationStatus.Success : ValidationStatus.Error;
}