diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/Entities/User.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/Entities/User.cs | 44 |
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> |
