From 8656254ff53aa4ec07cf8120dea2dfb2a0322d5f Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Tue, 22 Apr 2025 23:04:21 +0200 Subject: [PATCH] added user password hashing --- src/QuickDish.Core/User.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/QuickDish.Core/User.cs b/src/QuickDish.Core/User.cs index 1340901..a7417ba 100644 --- a/src/QuickDish.Core/User.cs +++ b/src/QuickDish.Core/User.cs @@ -12,4 +12,20 @@ internal class User public string Username { get; set; } public string PasswordHash { get; set; } + public User(int id, string username, string passwordHash) + { + if (id <= 0) + throw new ArgumentOutOfRangeException("User Id must be positiv", nameof(id)); + + if (string.IsNullOrWhiteSpace(username)) + throw new ArgumentException("Username can't be empty", nameof(username)); + + if (string.IsNullOrWhiteSpace(passwordHash)) + throw new ArgumentException("Password hash can't be empty", nameof(passwordHash)); + + Id = id; + Username = username; + PasswordHash = passwordHash; + } + }