aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-23 09:34:03 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-23 09:34:03 +0200
commit5bec920df45bb79e5912a97f2d0afc1a849adbd2 (patch)
treea0a4a7b62df4bae64b4fb45760f445baad21f4e4 /Software/Visual_Studio/Web/Tango.MachineService
parente0b0859f62924d38c8cd7ac9975303c4bfb08624 (diff)
downloadTango-5bec920df45bb79e5912a97f2d0afc1a849adbd2.tar.gz
Tango-5bec920df45bb79e5912a97f2d0afc1a849adbd2.zip
Fixed some issues with observables generator.
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs60
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj6
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Web.config4
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/packages.config1
4 files changed, 70 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
index ed1a807be..8225d75e1 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.IdentityModel.Clients.ActiveDirectory;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -6,10 +7,13 @@ using System.Net.Http;
using System.Security.Authentication;
using System.Web.Http;
using Tango.BL;
+using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
+using Tango.Core.Cryptography;
using Tango.MachineService.Helpers;
using Tango.MachineService.Models;
+using Tango.MachineStudio.Common.Authentication;
using Tango.MachineStudio.Common.Update;
namespace Tango.MachineService.Controllers
@@ -23,6 +27,8 @@ namespace Tango.MachineService.Controllers
_pendingUploads = new List<MachineStudioPendingUpload>();
}
+ #region Update
+
[HttpPost]
public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request)
{
@@ -182,5 +188,57 @@ namespace Tango.MachineService.Controllers
return new LatestVersionResponse() { Version = version != null ? version.Version : "0.0.0.0" };
}
}
+
+ #endregion
+
+ public LoginResponse Login(LoginRequest request)
+ {
+ var authContext = new AuthenticationContext("https://login.microsoftonline.com/2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4");
+ UserCredential userCredential = new UserCredential(request.Email, request.Password);
+ AuthenticationResult authResult = authContext.AcquireToken("https://graph.windows.net/", "ec612854-7abc-457b-808a-5d0c5ba80c57", userCredential);
+
+ using (ObservablesContext db = ObservablesContextHelper.CreateContext())
+ {
+
+ db.Roles.ToList();
+ db.Permissions.ToList();
+ db.UsersRoles.ToList();
+ db.RolesPermissions.ToList();
+
+ var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password);
+
+ if (user == null)
+ {
+ //Than add the user !!
+
+ IHashGenerator g = new BasicHashGenerator();
+
+ BL.Entities.User new_user = new User();
+ new_user.Email = request.Email;
+ new_user.Password = g.Encrypt("Aa123456");
+ new_user.Organization = db.Organizations.Single(x => x.Name == "Twine");
+ new_user.Address = new Address() { };
+ new_user.Contact = new Contact()
+ {
+ FirstName = authResult.UserInfo.GivenName,
+ LastName = authResult.UserInfo.FamilyName,
+ };
+ new_user.Roles.Add(db.Roles.Single(x => (Roles)x.Code == Roles.User));
+ }
+ }
+
+ return new LoginResponse()
+ {
+ DataSource = new Core.DataSource()
+ {
+ Address = Config.DB_ADDRESS,
+ Catalog = Config.DB_CATALOG,
+ Type = Core.DataSourceType.Azure,
+ UserName = request.Email,
+ Password = request.Password,
+ }
+ };
+ }
+
}
}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
index c6245e18e..5b13d8afd 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
@@ -64,6 +64,12 @@
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
+ <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.7.10707.1513-rc\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.SqlServer.AzureStorageEnum, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.SqlManagementObjects.140.17283.0\lib\net40\Microsoft.SqlServer.AzureStorageEnum.dll</HintPath>
</Reference>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
index 3590b89d8..ef2420349 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
@@ -125,6 +125,10 @@
<assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/packages.config b/Software/Visual_Studio/Web/Tango.MachineService/packages.config
index ede4fa80d..080382800 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/packages.config
+++ b/Software/Visual_Studio/Web/Tango.MachineService/packages.config
@@ -20,6 +20,7 @@
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net45" />
+ <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.7.10707.1513-rc" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net46" developmentDependency="true" />
<package id="Microsoft.SqlServer.SqlManagementObjects" version="140.17283.0" targetFramework="net461" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />