diff --git a/FoodsharingSiegen.Contracts/Entity/Enums.cs b/FoodsharingSiegen.Contracts/Entity/Enums.cs
index af949e1..2baf57c 100644
--- a/FoodsharingSiegen.Contracts/Entity/Enums.cs
+++ b/FoodsharingSiegen.Contracts/Entity/Enums.cs
@@ -17,11 +17,7 @@ namespace FoodsharingSiegen.Contracts.Entity
/// The save profile audit type
///
SaveProfile = 10,
-
- ///
- /// The set own password audit type
- ///
- SetOwnPassword = 20,
+
#region Usermanagement
diff --git a/FoodsharingSiegen.Server/Data/AuditHelper.cs b/FoodsharingSiegen.Server/Data/AuditHelper.cs
index cec1752..252d419 100644
--- a/FoodsharingSiegen.Server/Data/AuditHelper.cs
+++ b/FoodsharingSiegen.Server/Data/AuditHelper.cs
@@ -20,8 +20,6 @@ namespace FoodsharingSiegen.Server.Data
{
case AuditType.SaveProfile:
return "hat das eigene Profil gespeichert.";
- case AuditType.SetOwnPassword:
- return "hat das eigene Passwort geƤndert.";
case AuditType.CreateUser:
return $"hat den User {audit.Data1} erstellt.";
case AuditType.UpdateUser:
diff --git a/FoodsharingSiegen.Server/Data/Service/UserService.cs b/FoodsharingSiegen.Server/Data/Service/UserService.cs
index 3d1387b..f9b7325 100644
--- a/FoodsharingSiegen.Server/Data/Service/UserService.cs
+++ b/FoodsharingSiegen.Server/Data/Service/UserService.cs
@@ -11,6 +11,8 @@ namespace FoodsharingSiegen.Server.Data.Service
///
public class UserService : ServiceBase
{
+ private AuditService AuditService { get; }
+
#region Setup/Teardown
///
@@ -18,7 +20,8 @@ namespace FoodsharingSiegen.Server.Data.Service
///
/// The context
///
- public UserService(FsContext context, AuthService authService) : base(context, authService) { }
+ ///
+ public UserService(FsContext context, AuthService authService, AuditService auditService) : base(context, authService) => AuditService = auditService;
#endregion
@@ -46,6 +49,8 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveResult = await Context.SaveChangesAsync();
if (saveResult == 0) return new OperationResult(new Exception("Fehler bei der Registrierung"));
+ await AuditService.Insert(AuditType.CreateUser, user.Mail);
+
return new OperationResult(user);
}
catch (Exception e)
@@ -100,6 +105,10 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));
+
+ var auditData = CurrentUser?.Id == user.Id ? "sich selbst" : user.Mail;
+ await AuditService.Insert(AuditType.SetUserPassword, auditData);
+
return new OperationResult();
}
catch (Exception e)
@@ -146,6 +155,7 @@ namespace FoodsharingSiegen.Server.Data.Service
var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));
+ await AuditService.Insert(AuditType.UpdateUser, user.Mail);
return new OperationResult();
}
catch (Exception e)