Compare commits
4 Commits
c0c18f2ddd
...
f4f04e4a42
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4f04e4a42 | ||
|
|
6807f2b6e6 | ||
|
|
0dd0c1bf4c | ||
|
|
87f26f9367 |
@@ -62,7 +62,32 @@ namespace FoodsharingSiegen.Contracts.Enums
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The remove interaction audit type
|
/// The remove interaction audit type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
RemoveInteraction = 100
|
RemoveInteraction = 100,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The delete prospect images audit type
|
||||||
|
/// </summary>
|
||||||
|
DeleteProspectImages = 110,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The view prospect images audit type
|
||||||
|
/// </summary>
|
||||||
|
ViewProspectImages = 120,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The upload prospect image audit type
|
||||||
|
/// </summary>
|
||||||
|
UploadProspectImage = 130,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The request password reset audit type
|
||||||
|
/// </summary>
|
||||||
|
RequestPasswordReset = 140,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The change own password audit type
|
||||||
|
/// </summary>
|
||||||
|
ChangeOwnPassword = 150
|
||||||
|
|
||||||
#endregion Prospects
|
#endregion Prospects
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,6 +251,14 @@ namespace FoodsharingSiegen.Server.Auth
|
|||||||
user.ResetToken = resetToken;
|
user.ResetToken = resetToken;
|
||||||
user.ResetTokenExpiry = DateTime.UtcNow.AddMinutes(30);
|
user.ResetTokenExpiry = DateTime.UtcNow.AddMinutes(30);
|
||||||
|
|
||||||
|
Context.Audits?.Add(new Audit
|
||||||
|
{
|
||||||
|
Created = DateTime.Now,
|
||||||
|
Type = AuditType.RequestPasswordReset,
|
||||||
|
UserID = user.Id,
|
||||||
|
Data1 = user.Mail
|
||||||
|
});
|
||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
var resetLink = $"{baseUri.TrimEnd('/')}/reset-password/{resetToken}";
|
var resetLink = $"{baseUri.TrimEnd('/')}/reset-password/{resetToken}";
|
||||||
|
|||||||
@@ -43,7 +43,20 @@ namespace FoodsharingSiegen.Server.Controls
|
|||||||
{
|
{
|
||||||
var headerText = $"{type.Translate(AppSettings)} für {Prospect.Name} eintragen";
|
var headerText = $"{type.Translate(AppSettings)} für {Prospect.Name} eintragen";
|
||||||
|
|
||||||
await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, OnDataChanged));
|
Func<Task> onSuccess = async () =>
|
||||||
|
{
|
||||||
|
if (type == InteractionType.IdCheck && Prospect.Images != null && Prospect.Images.Count > 0)
|
||||||
|
{
|
||||||
|
await ConfirmDialog.ShowAsync(ModalService, "Personalausweisbilder löschen?", $"Möchtest du die Personalausweisbilder von {Prospect.Name} löschen? Diese werden für die weitere Bearbeitung nicht mehr benötigt und enthalten persönliche Daten.", async () =>
|
||||||
|
{
|
||||||
|
var result = await ProspectService.DeleteVerificationImagesAsync(Prospect.Id);
|
||||||
|
await OnDataChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await OnDataChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, onSuccess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,16 @@ namespace FoodsharingSiegen.Server.Data
|
|||||||
return $"hat dem Neuling {audit.Data1} folgendes hinzugefügt: {audit.Data2}";
|
return $"hat dem Neuling {audit.Data1} folgendes hinzugefügt: {audit.Data2}";
|
||||||
case AuditType.RemoveInteraction:
|
case AuditType.RemoveInteraction:
|
||||||
return $"hat eine Interaktion bei {audit.Data1} gelöscht.";
|
return $"hat eine Interaktion bei {audit.Data1} gelöscht.";
|
||||||
|
case AuditType.DeleteProspectImages:
|
||||||
|
return $"hat die Bilder von {audit.Data1} gelöscht.";
|
||||||
|
case AuditType.ViewProspectImages:
|
||||||
|
return $"hat die Bilder von {audit.Data1} angesehen.";
|
||||||
|
case AuditType.UploadProspectImage:
|
||||||
|
return $"hat ein Bild für {audit.Data1} hochgeladen.";
|
||||||
|
case AuditType.RequestPasswordReset:
|
||||||
|
return $"hat ein Passwort-Reset für {audit.Data1} angefordert.";
|
||||||
|
case AuditType.ChangeOwnPassword:
|
||||||
|
return $"hat das eigene Passwort geändert.";
|
||||||
case AuditType.None:
|
case AuditType.None:
|
||||||
default:
|
default:
|
||||||
return $"{audit.Data1}, {audit.Data2}";
|
return $"{audit.Data1}, {audit.Data2}";
|
||||||
|
|||||||
@@ -61,29 +61,56 @@ namespace FoodsharingSiegen.Server.Data.Service
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Method Load
|
#region Public Method GetCount
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the count (a. beging, 23.05.2022)
|
/// Gets the total count (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count">The count</param>
|
|
||||||
/// <param name="type">The type</param>
|
/// <param name="type">The type</param>
|
||||||
/// <returns>A task containing an operation result of list audit</returns>
|
/// <returns>A task containing an operation result of count</returns>
|
||||||
public async Task<OperationResult<List<Audit>>> Load(int count, AuditType? type = null)
|
public async Task<OperationResult<int>> GetCount(AuditType? type = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Task.CompletedTask;
|
var query = Context.Audits?.AsQueryable();
|
||||||
|
|
||||||
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
|
||||||
|
|
||||||
if (count > 0)
|
|
||||||
query = query?.Take(count);
|
|
||||||
|
|
||||||
if (type != null)
|
if (type != null)
|
||||||
query = query?.Where(x => x.Type == type);
|
query = query?.Where(x => x.Type == type);
|
||||||
|
|
||||||
var mat = query?.ToList();
|
if (query == null) return new(0);
|
||||||
|
|
||||||
|
var count = await query.CountAsync();
|
||||||
|
return new(count);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Method LoadPage
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the page of audits (ab)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="skip">The skip count</param>
|
||||||
|
/// <param name="take">The take count</param>
|
||||||
|
/// <param name="type">The type</param>
|
||||||
|
/// <returns>A task containing an operation result of list audit</returns>
|
||||||
|
public async Task<OperationResult<List<Audit>>> LoadPage(int skip, int take, AuditType? type = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable();
|
||||||
|
|
||||||
|
if (type != null)
|
||||||
|
query = query?.Where(x => x.Type == type);
|
||||||
|
|
||||||
|
query = query?.Skip(skip).Take(take);
|
||||||
|
|
||||||
|
var mat = await query!.ToListAsync();
|
||||||
|
|
||||||
if (mat != null) return new(mat);
|
if (mat != null) return new(mat);
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,8 @@ namespace FoodsharingSiegen.Server.Data.Service
|
|||||||
await Context.ProspectImages!.AddAsync(image);
|
await Context.ProspectImages!.AddAsync(image);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
|
await AuditService.Insert(AuditType.UploadProspectImage, prospect.Name);
|
||||||
|
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -308,6 +310,16 @@ namespace FoodsharingSiegen.Server.Data.Service
|
|||||||
.OrderBy(x => x.Created)
|
.OrderBy(x => x.Created)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
var prospectName = await Context.Prospects!
|
||||||
|
.Where(x => x.Id == prospectId)
|
||||||
|
.Select(x => x.Name)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(prospectName))
|
||||||
|
{
|
||||||
|
await AuditService.Insert(AuditType.ViewProspectImages, prospectName);
|
||||||
|
}
|
||||||
|
|
||||||
return new(images);
|
return new(images);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -329,6 +341,7 @@ namespace FoodsharingSiegen.Server.Data.Service
|
|||||||
if (prospect != null)
|
if (prospect != null)
|
||||||
{
|
{
|
||||||
prospect.VerificationToken = null; // Clear token when images are deleted
|
prospect.VerificationToken = null; // Clear token when images are deleted
|
||||||
|
await AuditService.Insert(AuditType.DeleteProspectImages, prospect.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|||||||
@@ -151,8 +151,14 @@ namespace FoodsharingSiegen.Server.Data.Service
|
|||||||
|
|
||||||
if (saveR < 1) return new(new Exception("Fehler beim Speichern"));
|
if (saveR < 1) return new(new Exception("Fehler beim Speichern"));
|
||||||
|
|
||||||
var auditData = CurrentUser?.Id == user.Id ? "sich selbst" : user.Mail;
|
if (CurrentUser?.Id == user.Id)
|
||||||
await AuditService.Insert(AuditType.SetUserPassword, auditData);
|
{
|
||||||
|
await AuditService.Insert(AuditType.ChangeOwnPassword);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await AuditService.Insert(AuditType.SetUserPassword, user.Mail);
|
||||||
|
}
|
||||||
|
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,10 @@ namespace FoodsharingSiegen.Server.Dialogs
|
|||||||
Interaction.UserID = CurrentUser.Id;
|
Interaction.UserID = CurrentUser.Id;
|
||||||
|
|
||||||
var addR = await ProspectService.AddInteraction(Interaction);
|
var addR = await ProspectService.AddInteraction(Interaction);
|
||||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
|
||||||
|
|
||||||
await ModalService.Hide();
|
await ModalService.Hide();
|
||||||
|
|
||||||
|
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
<DataGrid TItem="Audit"
|
<DataGrid TItem="Audit"
|
||||||
Data="@Audits"
|
Data="@Audits"
|
||||||
|
ReadData="@OnReadData"
|
||||||
|
TotalItems="@TotalAudits"
|
||||||
VirtualizeOptions="@(new() { DataGridHeight = "100%", DataGridMaxHeight = "100%"})"
|
VirtualizeOptions="@(new() { DataGridHeight = "100%", DataGridMaxHeight = "100%"})"
|
||||||
Virtualize="true"
|
Virtualize="true"
|
||||||
Responsive>
|
Responsive>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using Blazorise.DataGrid;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
|
using FoodsharingSiegen.Contracts.Helper;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
@@ -26,16 +28,47 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<Audit>? Audits { get; set; }
|
private List<Audit>? Audits { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the total audits (ab)
|
||||||
|
/// </summary>
|
||||||
|
private int TotalAudits { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Override InitializeDataAsync
|
#region Override InitializeDataAsync
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task InitializeDataAsync()
|
protected override Task InitializeDataAsync()
|
||||||
{
|
{
|
||||||
var loadR = await AuditService?.Load(100)!;
|
if (!CurrentUser.IsAdmin()) NavigationManager.NavigateTo("/");
|
||||||
if (loadR.Success)
|
return Task.CompletedTask;
|
||||||
Audits = loadR.Data;
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method OnReadData
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when data is read (ab)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The params</param>
|
||||||
|
private async Task OnReadData(DataGridReadDataEventArgs<Audit> e)
|
||||||
|
{
|
||||||
|
if (!CurrentUser.IsAdmin()) return;
|
||||||
|
|
||||||
|
var countLoad = await AuditService?.GetCount()!;
|
||||||
|
if (countLoad.Success)
|
||||||
|
TotalAudits = countLoad.Data;
|
||||||
|
|
||||||
|
// Default fallback if VirtualizeCount is not set, though Blazor shouldn't do this usually
|
||||||
|
var limit = e.VirtualizeCount > 0 ? e.VirtualizeCount : 50;
|
||||||
|
var offset = e.VirtualizeOffset;
|
||||||
|
|
||||||
|
var itemsLoad = await AuditService?.LoadPage(offset, limit)!;
|
||||||
|
if (itemsLoad.Success)
|
||||||
|
Audits = itemsLoad.Data;
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
{
|
{
|
||||||
<div class="alert alert-success text-center">
|
<div class="alert alert-success text-center">
|
||||||
Wenn ein Benutzerkonto mit dieser E-Mail-Adresse existiert, wurde eine E-Mail mit weiteren Anweisungen versendet.
|
Wenn ein Benutzerkonto mit dieser E-Mail-Adresse existiert, wurde eine E-Mail mit weiteren Anweisungen versendet.
|
||||||
|
<br><br>
|
||||||
|
<small><b>Hinweis:</b> Bitte überprüfe auch deinen Spam-Ordner, falls du künftige E-Mails nicht im regulären Posteingang findest.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center mt-4">
|
<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>
|
<a href="/login" class="btn btn-outline-primary"><i class="fas fa-arrow-left mr-2"></i> Zurück zum Login</a>
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Soll eine E-Mail zum Festlegen des Passworts an {user.Mail} gesendet werden?", async () =>
|
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Soll eine E-Mail zum Festlegen des Passworts an {user.Mail} gesendet werden?", async () =>
|
||||||
{
|
{
|
||||||
await AuthService.InitiateInitialPasswordSetup(user.Mail, NavigationManager.BaseUri);
|
await AuthService.InitiateInitialPasswordSetup(user.Mail, NavigationManager.BaseUri);
|
||||||
|
if (Notification != null)
|
||||||
|
{
|
||||||
|
await Notification.Success("E-Mail gesendet. Bitte weise den Benutzer darauf hin, auch den Spam-Ordner zu prüfen.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
<div @onclick="NavLinkClickedAsync">
|
<div @onclick="NavLinkClickedAsync">
|
||||||
@@ -73,6 +72,7 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="flex-grow-1"></div>
|
<div class="flex-grow-1"></div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user