aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-02-20 08:55:29 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-02-20 08:55:29 +0200
commita23cfede23d891712d2a2b840373075968f08994 (patch)
tree3ca77277ffaf20f4a4332b2321e913553bf1e300 /Software/Visual_Studio/Web/Tango.MachineService
parent38009a30108ff250ac4884bf85a89014db27b3bd (diff)
parentb740f2922a16a3df2897a4acbfca94bb87685045 (diff)
downloadTango-a23cfede23d891712d2a2b840373075968f08994.tar.gz
Tango-a23cfede23d891712d2a2b840373075968f08994.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs15
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs4
2 files changed, 9 insertions, 10 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);
}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs
index 5e41e0d8a..ead64fb38 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs
@@ -317,7 +317,7 @@ namespace Tango.MachineService.Controllers
var user_guid = TokensManager.GetTokenObject(request.AccessToken).UserGuid;
- var user = db.Users.SingleOrDefault(x => x.Guid == user_guid);
+ var user = new UserBuilder(db).Set(user_guid).WithRolesAndPermissions().Build();
if (user != null && user.HasPermission(Permissions.PublishPPCVersions))
{
@@ -432,7 +432,7 @@ namespace Tango.MachineService.Controllers
BasicHashGenerator hash = new BasicHashGenerator();
String pass = hash.Encrypt(request.Password);
- var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == pass);
+ var user = new UserBuilder(db).Set(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == pass).Build();
if (user == null)
{