From 908238244f88ae1c210795bc653178df92d75c59 Mon Sep 17 00:00:00 2001 From: Kim Date: Fri, 8 Sep 2023 16:13:36 +0200 Subject: [PATCH] null passwords for new users --- csharp/App/Backend/DataTypes/Methods/Session.cs | 2 +- csharp/App/Backend/DataTypes/Methods/User.cs | 2 +- csharp/App/Backend/DataTypes/User.cs | 2 +- csharp/App/S3Explorer/Program.cs | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/csharp/App/Backend/DataTypes/Methods/Session.cs b/csharp/App/Backend/DataTypes/Methods/Session.cs index 8f2ee1191..9dddd78e7 100644 --- a/csharp/App/Backend/DataTypes/Methods/Session.cs +++ b/csharp/App/Backend/DataTypes/Methods/Session.cs @@ -158,7 +158,7 @@ public static class SessionMethods && newUser .WithParent(sessionUser) .Do(() => newUser.MustResetPassword = true) - .Do(() => newUser.Password = newUser.SaltAndHashPassword(newUser.Password)) + .Do(() => newUser.Password = null) .Apply(Db.Create); // && Mailer.Mailer.SendVerificationMessage(newUser); diff --git a/csharp/App/Backend/DataTypes/Methods/User.cs b/csharp/App/Backend/DataTypes/Methods/User.cs index 8cf801112..f1913ee99 100644 --- a/csharp/App/Backend/DataTypes/Methods/User.cs +++ b/csharp/App/Backend/DataTypes/Methods/User.cs @@ -97,7 +97,7 @@ public static class UserMethods } - public static String SaltAndHashPassword(this User user, String password) + public static String? SaltAndHashPassword(this User user, String password) { var dataToHash = $"{password}{user.Salt()}"; diff --git a/csharp/App/Backend/DataTypes/User.cs b/csharp/App/Backend/DataTypes/User.cs index a9c6b4bdd..7397eb6e2 100644 --- a/csharp/App/Backend/DataTypes/User.cs +++ b/csharp/App/Backend/DataTypes/User.cs @@ -8,7 +8,7 @@ public class User : TreeNode public Boolean HasWriteAccess { get; set; } = false; public Boolean MustResetPassword { get; set; } = false; public String Language { get; set; } = null!; - public String Password { get; set; } = null!; + public String? Password { get; set; } = null!; [Unique] public override String Name { get; set; } = null!; diff --git a/csharp/App/S3Explorer/Program.cs b/csharp/App/S3Explorer/Program.cs index f9ec9c350..287b9aa56 100644 --- a/csharp/App/S3Explorer/Program.cs +++ b/csharp/App/S3Explorer/Program.cs @@ -33,7 +33,7 @@ public static class Program var startTime = Int64.Parse(args.ElementAtOr(1, (now - UnixTimeSpan.FromSeconds(20)).ToString())); var endTime = Int64.Parse(args.ElementAtOr(2, now.ToString())); - var nDataPoints = Int64.Parse(args.ElementAtOr(3, "11")) - 1 ; + var nDataPoints = Int64.Parse(args.ElementAtOr(3, "10")); var timestampList = GetDataTimestamps(startTime, endTime, nDataPoints); @@ -47,17 +47,17 @@ public static class Program { // Calculating temporal distance of data files from the number of requested points. (rounding for int division) var timeSpan = endTime - startTime; - var timeBetweenDataPoints1 = (timeSpan + nDataPoints -1) / nDataPoints; - + var timeBetweenDataPoints = (Double)(timeSpan / nDataPoints); + timeBetweenDataPoints = Math.Max(2, timeBetweenDataPoints); // We only upload data every second second so sampling more is impossible. // If this ever changes we might have to change this as well. - var timeBetweenDataPoints = Math.Max(timeBetweenDataPoints1, 2); - + // Building a List of the timestamps we want to grab the files for. - for (var i = startTime; i <= endTime; i += timeBetweenDataPoints) + for (Double i = startTime; i <= endTime; i += timeBetweenDataPoints) { //Rounding to even numbers only (we only save every second second) - yield return i%2 != 0 ? i+1 : i; + var integer = (Int64) Math.Round(i); + yield return integer/2 * 2; } }