aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.BL/Entities/User.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.BL/Entities/User.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/Entities/User.cs')
-rw-r--r--Software/Visual_Studio/Tango.BL/Entities/User.cs44
1 files changed, 37 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Tango.BL/Entities/User.cs b/Software/Visual_Studio/Tango.BL/Entities/User.cs
index dc27b5625..7c6780972 100644
--- a/Software/Visual_Studio/Tango.BL/Entities/User.cs
+++ b/Software/Visual_Studio/Tango.BL/Entities/User.cs
@@ -16,6 +16,8 @@ namespace Tango.BL.Entities
{
private static IHashGenerator _hashGenerator;
+ private bool _passwordGatewayModified = false;
+
/// <summary>
/// Determines whether the user has the specified permission.
/// </summary>
@@ -38,7 +40,7 @@ namespace Tango.BL.Entities
}
/// <summary>
- /// Gets the aggregated user roles.
+ /// Gets the aggregated user roles as enumerations.
/// </summary>
[NotMapped]
public List<Role> Roles
@@ -47,29 +49,49 @@ namespace Tango.BL.Entities
}
/// <summary>
- /// Gets the aggregated FSE user roles.
+ /// Gets the aggregated user permissions as enumerations.
/// </summary>
[NotMapped]
- public List<Role> FSERoles
+ public List<Permission> Permissions
{
- get { return UsersRoles.Select(x => x.Role).Where(x => x.Name.StartsWith("FSE")).ToList(); }
+ get
+ {
+ return UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).Select(x => x.Permission).ToList();
+ }
}
+
+ private String _passwordGateway;
/// <summary>
- /// Gets the aggregated user permissions as enumerations.
+ /// Gets or sets the password gate way.
/// </summary>
[NotMapped]
- public List<Permission> Permissions
+ [JsonIgnore]
+ [XmlIgnore]
+ public String PasswordGateWay
{
get
{
- return UsersRoles.Select(x => x.Role).ToList().SelectMany(x => x.RolesPermissions).Select(x => x.Permission).ToList();
+ return _passwordGateway;
+ }
+ set
+ {
+ _passwordGateway = value;
+ Password = GetHashGenerator().Encrypt(_passwordGateway);
+ RaisePropertyChangedAuto();
+
+ _passwordGatewayModified = true;
}
}
protected override void RaisePropertyChanged(string propName)
{
base.RaisePropertyChanged(propName);
+
+ if (propName == nameof(Password))
+ {
+ RaisePropertyChanged(nameof(PasswordGateWay));
+ }
}
public override bool Validate(ObservablesContext context)
@@ -92,6 +114,14 @@ namespace Tango.BL.Entities
{
InsertError(nameof(Email), "The specified email address is invalid.");
}
+
+ if (_passwordGatewayModified)
+ {
+ if (!PasswordGateWay.IsBetweenLength(4, 30))
+ {
+ InsertError(nameof(PasswordGateWay), "A user password must be at least 4 characters long and maximum 30.");
+ }
+ }
}
/// <summary>