aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs15
1 files changed, 7 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
index 82082ca2f..054c8d781 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
@@ -145,15 +145,9 @@ namespace Tango.MachineService.Controllers
using (ObservablesContext db = ObservablesContextHelper.CreateContext())
{
- //Load relation first...
- db.Roles.ToList();
- db.Permissions.ToList();
- db.UsersRoles.ToList();
- db.RolesPermissions.ToList();
-
String userID = TokensManager.GetTokenObject(request.AccessToken);
- var user = db.Users.SingleOrDefault(x => x.Guid == userID);
+ var user = new UserBuilder(db).Set(userID).WithRolesAndPermissions().Build();
if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersions))
{
@@ -281,7 +275,7 @@ namespace Tango.MachineService.Controllers
db.UsersRoles.ToList();
db.RolesPermissions.ToList();
- user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower());
+ user = new UserBuilder(db).Set(x => x.Email.ToLower() == request.Email.ToLower()).WithRolesAndPermissions().WithDeleted().Build();
IHashGenerator g = new BasicHashGenerator();
@@ -318,6 +312,11 @@ namespace Tango.MachineService.Controllers
}
else
{
+ if (user.Deleted)
+ {
+ throw new AuthenticationException("Your account has been disabled. Please contact your administrator.");
+ }
+
user.LastLogin = DateTime.UtcNow;
user.Password = g.Encrypt(request.Password);
}