diff --git a/MCTG/MCTGLib/IPasswordManager.cs b/MCTG/MCTGLib/IPasswordManager.cs new file mode 100644 index 0000000..2473a32 --- /dev/null +++ b/MCTG/MCTGLib/IPasswordManager.cs @@ -0,0 +1,17 @@ +using MCTGLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public interface IPasswordManager + { + public void changePassword(User user, string newPassword); + public string HashPassword(User user); + public bool VerifyPassword(string hashedPassword); + + } +} diff --git a/MCTG/MCTGLib/PasswordManager.cs b/MCTG/MCTGLib/PasswordManager.cs new file mode 100644 index 0000000..2ed6017 --- /dev/null +++ b/MCTG/MCTGLib/PasswordManager.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class PasswordManager : IPasswordManager + { + } +} diff --git a/MCTG/MCTGLib/User.cs b/MCTG/MCTGLib/User.cs index 4cda05a..27c96f1 100644 --- a/MCTG/MCTGLib/User.cs +++ b/MCTG/MCTGLib/User.cs @@ -12,7 +12,7 @@ namespace MCTGLib /// A user is an entity with a name, a surname, mail, profilePict and a list of priority. /// This user can login with a Id and password /// - public class User + public class User : IEquatable { #region Private Attributes @@ -21,8 +21,7 @@ namespace MCTGLib private string mail = ""; private string picture = ""; private string password = ""; - //private bool isAdmin; - private string defaultUserSavePath = ""; + //private string defaultUserSavePath = ""; private List priorities; #endregion @@ -70,7 +69,7 @@ namespace MCTGLib public string Mail { get { return mail; } - init + private init { if (string.IsNullOrWhiteSpace(value)) { @@ -79,6 +78,17 @@ namespace MCTGLib mail = value; } } + + /// + /// Property to initiate password, change it, and + /// + public string Password + { + get { return password; } + + set { password = value; } + } + /// /// For now, we define the ProfilPict as a string which is "PhotoParDefaut" /// when the value is null. @@ -90,25 +100,6 @@ namespace MCTGLib } - - /// - ///Password property - /// - public string Password - { - get => password; - private set - { - string modelPassword = @"[a-z]*[A-Z]+$" ; - if (!string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Le mot de passe ne doit pas etre vide "); - } - // if (Regex.IsMatch(value, modelPassword, RegexOptions. ) - } - - } - /// /// This is the list of priorities specific tu the user. This list is initiate /// by default. User could change it at will. @@ -120,6 +111,11 @@ namespace MCTGLib set=> priorities = value; } + public bool Equals(User other) + { + return Name.Equals(other.Name) && Surname.Equals(other.Surname) && Mail.Equals(other.Mail) && ; + } + #endregion @@ -137,7 +133,6 @@ namespace MCTGLib Name = name; Surname = surname; Mail = mail; - Password = password; priorities = new List { Priority.Gourmet, Priority.Economic, diff --git a/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj b/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj index 42ff44d..66ef51e 100644 --- a/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj +++ b/MCTG/Tests/MCTGLib_UnitTests/MCTGLib_UnitTests.csproj @@ -22,4 +22,8 @@ + + + + diff --git a/MCTG/Tests/MCTGLib_UnitTests/UnitTest1.cs b/MCTG/Tests/MCTGLib_UnitTests/UnitTest1.cs deleted file mode 100644 index 4d22b68..0000000 --- a/MCTG/Tests/MCTGLib_UnitTests/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MCTGLib_UnitTests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/MCTG/Tests/MCTGLib_UnitTests/test_unit_user.cs b/MCTG/Tests/MCTGLib_UnitTests/test_unit_user.cs new file mode 100644 index 0000000..822e958 --- /dev/null +++ b/MCTG/Tests/MCTGLib_UnitTests/test_unit_user.cs @@ -0,0 +1,19 @@ +using MCTGLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MCTGLib_UnitTests +{ + public class test_unit_user + { + [Fact] + public void TestConstructUser() + { + User user = new User("Bob","Dylan", "bd@gmail.com"); + Assert. + } + } +}