From b6fbeb48b53b5e4136abd83128e901919ba079f4 Mon Sep 17 00:00:00 2001 From: Kim Date: Thu, 6 Apr 2023 08:32:47 +0200 Subject: [PATCH] fixing bug in updating user --- csharp/App/Backend/DataTypes/Methods/Session.cs | 3 ++- csharp/App/Backend/Database/Update.cs | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/csharp/App/Backend/DataTypes/Methods/Session.cs b/csharp/App/Backend/DataTypes/Methods/Session.cs index c0e6b3e33..abf600074 100644 --- a/csharp/App/Backend/DataTypes/Methods/Session.cs +++ b/csharp/App/Backend/DataTypes/Methods/Session.cs @@ -157,6 +157,7 @@ public static class SessionMethods .Do(() => newUser.Password = newUser.SaltAndHashPassword(newUser.Password)) .Do(() => newUser.MustResetPassword = true) .Apply(Db.Create); + // && Mailer.Mailer.SendVerificationMessage(newUser); //Send Email to new user to verify email and set password @@ -172,7 +173,7 @@ public static class SessionMethods && sessionUser is not null && originalUser is not null && sessionUser.HasWriteAccess - && sessionUser.HasAccessTo(editedUser) + && sessionUser.HasAccessTo(originalUser) && editedUser .WithParentOf(originalUser) // prevent moving .WithNameOf(originalUser) diff --git a/csharp/App/Backend/Database/Update.cs b/csharp/App/Backend/Database/Update.cs index 923d81345..a90749a45 100644 --- a/csharp/App/Backend/Database/Update.cs +++ b/csharp/App/Backend/Database/Update.cs @@ -18,11 +18,13 @@ public static partial class Db public static Boolean Update(User user) { var originalUser = GetUserById(user.Id); - - return originalUser is not null - && user.ParentId == originalUser.ParentId // these columns must not be modified! - && user.Name == originalUser.Name - && Connection.Update(user) > 0; + if (originalUser is null) return false; + + // these columns must not be modified! + user.ParentId = originalUser.ParentId; + user.Name = originalUser.Name; + + return Connection.Update(user) > 0; }