null passwords for new users

This commit is contained in:
Kim 2023-09-08 16:13:36 +02:00
parent bd4ad2b16e
commit 908238244f
4 changed files with 10 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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