I tried to rethink the architecture of the user class. Now it's not working yet. But I tried to implement a IPasswordManager, a PasswordManager and implement some equals properties.
continuous-integration/drone/push Build is failing Details

pull/35/head^2
Roxane ROSSETTO 2 years ago
parent be78694fe6
commit 008c30b044

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

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

@ -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
/// </summary>
public class User
public class User : IEquatable<User>
{
#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<Priority> 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;
}
}
///<summary>
/// Property to initiate password, change it, and
/// </summary>
public string Password
{
get { return password; }
set { password = value; }
}
/// <summary>
/// For now, we define the ProfilPict as a string which is "PhotoParDefaut"
/// when the value is null.
@ -90,25 +100,6 @@ namespace MCTGLib
}
///<summary>
///Password property
/// </summary>
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. )
}
}
/// <summary>
/// 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> {
Priority.Gourmet,
Priority.Economic,

@ -22,4 +22,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MCTGLib\Model.csproj" />
</ItemGroup>
</Project>

@ -1,11 +0,0 @@
namespace MCTGLib_UnitTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

@ -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.
}
}
}
Loading…
Cancel
Save