diff --git a/.gitignore b/.gitignore
index 68a4b042..e32ff696 100644
--- a/.gitignore
+++ b/.gitignore
@@ -335,6 +335,7 @@ ASALocalRun/
Deploy/helm/__values/*
!Deploy/helm/__values/readme.txt
+Source\Services\Tailwind.Traders.Rewards.Registration.Api\Properties\PublishProfiles\*.pubxml
Source/Services/Tailwind.Traders.Cart.Api/.env
/Source/.env
diff --git a/Deploy/helm/gvalues.template b/Deploy/helm/gvalues.template
index f4c87cbe..0c8eef5b 100644
--- a/Deploy/helm/gvalues.template
+++ b/Deploy/helm/gvalues.template
@@ -73,6 +73,9 @@ inf:
stockapiurl: http://stock
imageclassifierapiurl: http://imageclassifier
loginapiurl: http://login
+ registrationusers:
+ registerusers: "false"
+ registrationusersurl: "TODO DEMI"
az:
productvisitsurl: ""
@@ -97,6 +100,16 @@ sec:
issuer: {{secissuer}}
securityKey: {{seckey}}
+B2C:
+ UseB2C: "false"
+ B2CIssuer: ""
+ Authority: ""
+ tenantID: ""
+ clientID: ""
+ policyName: ""
+ identityMetadata: ""
+ issuer: ""
+
# Autoscaling global settings
hpa:
activated: false # set to true to deploy HPA for services
diff --git a/Deploy/helm/gvalues.yaml b/Deploy/helm/gvalues.yaml
index 4dc33c93..9fe0bd44 100644
--- a/Deploy/helm/gvalues.yaml
+++ b/Deploy/helm/gvalues.yaml
@@ -78,6 +78,9 @@ inf:
stockapiurl: http://stock
imageclassifierapiurl: http://imageclassifier
loginapiurl: http://login
+ registrationusers:
+ registerusers: "false"
+ registrationusersurl: "TODO DEMI"
az:
productvisitsurl: ""
diff --git a/Deploy/helm/gvalues_inf.yaml b/Deploy/helm/gvalues_inf.yaml
index b81b8e77..7f95b06a 100644
--- a/Deploy/helm/gvalues_inf.yaml
+++ b/Deploy/helm/gvalues_inf.yaml
@@ -77,6 +77,9 @@ inf:
stockapiurl: http://stock
imageclassifierapiurl: http://imageclassifier
loginapiurl: http://login
+ registrationusers:
+ registerusers: "false"
+ registrationusersurl: "TODO DEMI"
az:
productvisitsurl: ""
@@ -100,6 +103,17 @@ ingress:
sec:
issuer: TTFakeLogin
securityKey: nEpLzQJGNSCNL5H6DIQCtTdNxf5VgAGcBbtXLms1YDD01KJBAs0WVawaEjn97uwB
+
+B2C:
+ UseB2C: "false"
+ B2CIssuer: ""
+ Authority: ""
+ tenantID: ""
+ clientID: ""
+ policyName: ""
+ identityMetadata: ""
+ issuer: ""
+
# Autoscaling global settings
hpa:
activated: false # set to true to deploy HPA for services
diff --git a/Deploy/helm/gvalues_inf_azds.yaml b/Deploy/helm/gvalues_inf_azds.yaml
index 07366664..a0c37af3 100644
--- a/Deploy/helm/gvalues_inf_azds.yaml
+++ b/Deploy/helm/gvalues_inf_azds.yaml
@@ -73,6 +73,9 @@ inf:
stockapiurl: http://stock
imageclassifierapiurl: http://imageclassifier
loginapiurl: http://login
+ registrationusers:
+ registerusers: "false"
+ registrationusersurl: "TODO DEMI: WCF SERVICE URL"
az:
productvisitsurl: ""
@@ -97,6 +100,16 @@ sec:
issuer: TTFakeLogin
securityKey: nEpLzQJGNSCNL5H6DIQCtTdNxf5VgAGcBbtXLms1YDD01KJBAs0WVawaEjn97uwB
+B2C:
+ UseB2C: "false"
+ B2CIssuer: ""
+ Authority: ""
+ tenantID: ""
+ clientID: ""
+ policyName: ""
+ identityMetadata: ""
+ issuer: ""
+
# Autoscaling global settings
hpa:
activated: false # set to true to deploy HPA for services
diff --git a/Deploy/helm/mobilebff/templates/configmap.yaml b/Deploy/helm/mobilebff/templates/configmap.yaml
index a479dd4d..36f7864a 100644
--- a/Deploy/helm/mobilebff/templates/configmap.yaml
+++ b/Deploy/helm/mobilebff/templates/configmap.yaml
@@ -20,4 +20,6 @@ data:
ISSUER: {{ .Values.sec.issuer }}
SECURITYKEY: {{ .Values.sec.securityKey }}
LoginApiUrl: {{ .Values.inf.apiurls.loginapiurl }}
+ RegisterUsers: {{ .Values.inf.registrationusers.registerusers | quote }}
+ RegistrationUsersEndpoint: {{ .Values.inf.registrationusers.registrationusersurl }}
diff --git a/Deploy/helm/mobilebff/values.yaml b/Deploy/helm/mobilebff/values.yaml
index ee3dbed1..c06fb7ee 100644
--- a/Deploy/helm/mobilebff/values.yaml
+++ b/Deploy/helm/mobilebff/values.yaml
@@ -33,6 +33,8 @@ env:
- name: ISSUER
- name: SECURITYKEY
- name: LoginApiUrl
+ - name: RegisterUsers
+ - name: RegistrationUsersEndpoint
values:
- name: ASPNETCORE_ENVIRONMENT
value: Development
diff --git a/Deploy/helm/webbff/templates/configmap.yaml b/Deploy/helm/webbff/templates/configmap.yaml
index f8a0697c..479b5fd0 100644
--- a/Deploy/helm/webbff/templates/configmap.yaml
+++ b/Deploy/helm/webbff/templates/configmap.yaml
@@ -23,5 +23,6 @@ data:
UseB2C: {{ .Values.B2C.UseB2C | quote }}
B2CIssuer: {{ .Values.B2C.B2CIssuer }}
Authority: {{ .Values.B2C.Authority }}
-
+ RegisterUsers: {{ .Values.inf.registrationusers.registerusers | quote }}
+ RegistrationUsersEndpoint: {{ .Values.inf.registrationusers.registrationusersurl }}
diff --git a/Deploy/helm/webbff/values.yaml b/Deploy/helm/webbff/values.yaml
index c0a0432b..84278111 100644
--- a/Deploy/helm/webbff/values.yaml
+++ b/Deploy/helm/webbff/values.yaml
@@ -37,6 +37,8 @@ env:
- name: UseB2C
- name: B2CIssuer
- name: Authority
+ - name: RegisterUsers
+ - name: RegistrationUsersEndpoint
values:
- name: ASPNETCORE_ENVIRONMENT
value: Development
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/AppSettings.cs b/Source/ApiGWs/Tailwind.Traders.Bff/AppSettings.cs
index ff4dce39..6c6a6197 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/AppSettings.cs
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/AppSettings.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Tailwind.Traders.MobileBff
+namespace Tailwind.Traders.MobileBff
{
public class AppSettings
{
@@ -14,5 +9,7 @@ public class AppSettings
public string LoginApiUrl { get; set; }
public string ImageClassifierApiUrl { get; set; }
public bool UseMlNetClassifier { get; set; }
+ public bool RegisterUsers { get; set; }
+ public string RegistrationUsersEndpoint { get; set; }
}
}
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/ConnectedService.json b/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/ConnectedService.json
new file mode 100644
index 00000000..9743a7f8
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/ConnectedService.json
@@ -0,0 +1,24 @@
+{
+ "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
+ "Version": "15.0.20628.921",
+ "ExtendedData": {
+ "Uri": "http://localhost:51402/UserService.svc",
+ "Namespace": "RegistrationUserService",
+ "SelectedAccessLevelForGeneratedClass": "Public",
+ "GenerateMessageContract": false,
+ "ReuseTypesinReferencedAssemblies": true,
+ "ReuseTypesinAllReferencedAssemblies": true,
+ "CollectionTypeReference": {
+ "Item1": "System.Array",
+ "Item2": "System.Runtime.dll"
+ },
+ "DictionaryCollectionTypeReference": {
+ "Item1": "System.Collections.Generic.Dictionary`2",
+ "Item2": "System.Collections.dll"
+ },
+ "CheckedReferencedAssemblies": [],
+ "InstanceId": null,
+ "Name": "RegistrationUserService",
+ "Metadata": {}
+ }
+}
\ No newline at end of file
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/Reference.cs b/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/Reference.cs
new file mode 100644
index 00000000..8fc2c380
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Connected Services/RegistrationUserService/Reference.cs
@@ -0,0 +1,127 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// //
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace RegistrationUserService
+{
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ [System.ServiceModel.ServiceContractAttribute(ConfigurationName="RegistrationUserService.IUserService")]
+ public interface IUserService
+ {
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IUserService/Registration", ReplyAction="http://tempuri.org/IUserService/RegistrationResponse")]
+ System.Threading.Tasks.Task RegistrationAsync(string email);
+ }
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ public interface IUserServiceChannel : RegistrationUserService.IUserService, System.ServiceModel.IClientChannel
+ {
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ public partial class UserServiceClient : System.ServiceModel.ClientBase, RegistrationUserService.IUserService
+ {
+
+ ///
+ /// Implement this partial method to configure the service endpoint.
+ ///
+ /// The endpoint to configure
+ /// The client credentials
+ static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
+
+ public UserServiceClient() :
+ base(UserServiceClient.GetDefaultBinding(), UserServiceClient.GetDefaultEndpointAddress())
+ {
+ this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IUserService.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), UserServiceClient.GetEndpointAddress(endpointConfiguration))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(binding, remoteAddress)
+ {
+ }
+
+ public System.Threading.Tasks.Task RegistrationAsync(string email)
+ {
+ return base.Channel.RegistrationAsync(email);
+ }
+
+ public virtual System.Threading.Tasks.Task OpenAsync()
+ {
+ return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
+ }
+
+ public virtual System.Threading.Tasks.Task CloseAsync()
+ {
+ return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IUserService))
+ {
+ System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
+ result.MaxBufferSize = int.MaxValue;
+ result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
+ result.MaxReceivedMessageSize = int.MaxValue;
+ result.AllowCookies = true;
+ return result;
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IUserService))
+ {
+ return new System.ServiceModel.EndpointAddress("http://localhost:51402/UserService.svc");
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetDefaultBinding()
+ {
+ return UserServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IUserService);
+ }
+
+ private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
+ {
+ return UserServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IUserService);
+ }
+
+ public enum EndpointConfiguration
+ {
+
+ BasicHttpBinding_IUserService,
+ }
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Controllers/LoginController.cs b/Source/ApiGWs/Tailwind.Traders.Bff/Controllers/LoginController.cs
index 8618676a..d2728eb0 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/Controllers/LoginController.cs
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Controllers/LoginController.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Tailwind.Traders.MobileBff.Infrastructure;
using Tailwind.Traders.MobileBff.Models;
+using Tailwind.Traders.MobileBff.Services;
namespace Tailwind.Traders.MobileBff.Controllers
{
@@ -19,15 +20,18 @@ namespace Tailwind.Traders.MobileBff.Controllers
public class LoginController : Controller
{
private readonly IHttpClientFactory _httpClientFactory;
+ private readonly IRegisterService _registerService;
private readonly AppSettings _settings;
private const string VERSION_API = "v1";
public LoginController(
IHttpClientFactory httpClientFactory,
- IOptions options)
+ IOptions options,
+ IRegisterService registerService)
{
_httpClientFactory = httpClientFactory;
_settings = options.Value;
+ _registerService = registerService;
}
// POST: v1/login
@@ -41,10 +45,16 @@ public async Task Login([FromBody] TokenRequest request)
var response = await client.PostAsync(API.Login.PostLogin(_settings.LoginApiUrl, VERSION_API), stringContent);
- if (response.StatusCode == HttpStatusCode.BadRequest) {
+ if (response.StatusCode == HttpStatusCode.BadRequest)
+ {
return BadRequest();
}
+ if (_settings.RegisterUsers)
+ {
+ await _registerService.RegisterUserIfNotExists(request.Username);
+ }
+
var result = await response.Content.ReadAsStringAsync();
var authResponse = JsonConvert.DeserializeObject(result);
return Ok(authResponse);
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Services/IRegisterService.cs b/Source/ApiGWs/Tailwind.Traders.Bff/Services/IRegisterService.cs
new file mode 100644
index 00000000..16593c4a
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Services/IRegisterService.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Tailwind.Traders.MobileBff.Services
+{
+ public interface IRegisterService
+ {
+ Task RegisterUserIfNotExists(string email);
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Services/RegisterService.cs b/Source/ApiGWs/Tailwind.Traders.Bff/Services/RegisterService.cs
new file mode 100644
index 00000000..449f1bb8
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Services/RegisterService.cs
@@ -0,0 +1,20 @@
+using RegistrationUserService;
+using System.Threading.Tasks;
+
+namespace Tailwind.Traders.MobileBff.Services
+{
+ public class RegisterService : IRegisterService
+ {
+ private readonly IUserService _client;
+
+ public RegisterService(IUserService client)
+ {
+ _client = client;
+ }
+
+ public async Task RegisterUserIfNotExists(string email)
+ {
+ return await _client.RegistrationAsync(email);
+ }
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Startup.cs b/Source/ApiGWs/Tailwind.Traders.Bff/Startup.cs
index ccf7bfa0..7af971a1 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/Startup.cs
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Startup.cs
@@ -5,10 +5,14 @@
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using RegistrationUserService;
using System;
+using System.ServiceModel;
using Tailwind.Traders.MobileBff;
using Tailwind.Traders.MobileBff.Infrastructure;
-
+using Tailwind.Traders.MobileBff.Services;
+using static RegistrationUserService.UserServiceClient;
+
namespace Tailwind.Traders.Bff
{
public class Startup
@@ -27,6 +31,11 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpClientServices(Configuration);
services.Configure(Configuration);
+ services.AddTransient(_ => new UserServiceClient(
+ EndpointConfiguration.BasicHttpBinding_IUserService,
+ new EndpointAddress(Configuration["RegistrationUsersEndpoint"])));
+
+ services.AddTransient();
services.AddSwaggerGen(options =>
{
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/Tailwind.Traders.MobileBff.csproj b/Source/ApiGWs/Tailwind.Traders.Bff/Tailwind.Traders.MobileBff.csproj
index 6f93cf8e..d8e0da1d 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/Tailwind.Traders.MobileBff.csproj
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/Tailwind.Traders.MobileBff.csproj
@@ -19,6 +19,14 @@
+
+
+
+
+
+
+
+
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.Development.json b/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.Development.json
index a2bf7b20..e931d56b 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.Development.json
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.Development.json
@@ -16,5 +16,7 @@
"ProfileApiUrl": "http://localhost:5001",
"CouponsApiUrl": "http://localhost:5002",
"ImageClassifierApiUrl": "http://localhost:5006",
- "LoginApiUrl": "http://localhost:5008"
+ "LoginApiUrl": "http://localhost:5008",
+ "RegisterUsers": false,
+ "RegistrationUsersEndpoint": "http://localhost:51402/UserService.svc"
}
diff --git a/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.json b/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.json
index 6a845cfd..08643b77 100644
--- a/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.json
+++ b/Source/ApiGWs/Tailwind.Traders.Bff/appsettings.json
@@ -4,5 +4,7 @@
"Default": "Information"
}
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+ "RegisterUsers": false,
+ "RegistrationUsersEndpoint": "http://localhost:51402/UserService.svc"
}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/AppSettings.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/AppSettings.cs
index 9929f422..e0bf14b2 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/AppSettings.cs
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/AppSettings.cs
@@ -1,12 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
namespace Tailwind.Traders.WebBff
{
public class AppSettings
{
+ private IConfigurationRoot configuration;
+
public string ProductsApiUrl { get; set; }
public string PopularProductsApiUrl { get; set; }
public string ProfileApiUrl { get; set; }
@@ -16,5 +15,7 @@ public class AppSettings
public bool UseMlNetClassifier { get; set; }
public string StockApiUrl { get; set; }
public string Authority { get; set; }
- }
+ public bool RegisterUsers { get; set; }
+ public string RegistrationUsersEndpoint { get; set; }
+ }
}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/ConnectedService.json b/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/ConnectedService.json
new file mode 100644
index 00000000..4728ceda
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/ConnectedService.json
@@ -0,0 +1,27 @@
+{
+ "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
+ "Version": "15.0.20628.921",
+ "GettingStartedDocument": {
+ "Uri": "https://go.microsoft.com/fwlink/?linkid=858517"
+ },
+ "ExtendedData": {
+ "Uri": "http://localhost:51402/UserService.svc",
+ "Namespace": "RegistrationUserService",
+ "SelectedAccessLevelForGeneratedClass": "Public",
+ "GenerateMessageContract": false,
+ "ReuseTypesinReferencedAssemblies": true,
+ "ReuseTypesinAllReferencedAssemblies": true,
+ "CollectionTypeReference": {
+ "Item1": "System.Array",
+ "Item2": "System.Runtime.dll"
+ },
+ "DictionaryCollectionTypeReference": {
+ "Item1": "System.Collections.Generic.Dictionary`2",
+ "Item2": "System.Collections.dll"
+ },
+ "CheckedReferencedAssemblies": [],
+ "InstanceId": null,
+ "Name": "RegistrationUserService",
+ "Metadata": {}
+ }
+}
\ No newline at end of file
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/Reference.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/Reference.cs
new file mode 100644
index 00000000..8fc2c380
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Connected Services/RegistrationUserService/Reference.cs
@@ -0,0 +1,127 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// //
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace RegistrationUserService
+{
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ [System.ServiceModel.ServiceContractAttribute(ConfigurationName="RegistrationUserService.IUserService")]
+ public interface IUserService
+ {
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IUserService/Registration", ReplyAction="http://tempuri.org/IUserService/RegistrationResponse")]
+ System.Threading.Tasks.Task RegistrationAsync(string email);
+ }
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ public interface IUserServiceChannel : RegistrationUserService.IUserService, System.ServiceModel.IClientChannel
+ {
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
+ public partial class UserServiceClient : System.ServiceModel.ClientBase, RegistrationUserService.IUserService
+ {
+
+ ///
+ /// Implement this partial method to configure the service endpoint.
+ ///
+ /// The endpoint to configure
+ /// The client credentials
+ static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
+
+ public UserServiceClient() :
+ base(UserServiceClient.GetDefaultBinding(), UserServiceClient.GetDefaultEndpointAddress())
+ {
+ this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IUserService.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), UserServiceClient.GetEndpointAddress(endpointConfiguration))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(UserServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public UserServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(binding, remoteAddress)
+ {
+ }
+
+ public System.Threading.Tasks.Task RegistrationAsync(string email)
+ {
+ return base.Channel.RegistrationAsync(email);
+ }
+
+ public virtual System.Threading.Tasks.Task OpenAsync()
+ {
+ return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
+ }
+
+ public virtual System.Threading.Tasks.Task CloseAsync()
+ {
+ return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IUserService))
+ {
+ System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
+ result.MaxBufferSize = int.MaxValue;
+ result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
+ result.MaxReceivedMessageSize = int.MaxValue;
+ result.AllowCookies = true;
+ return result;
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IUserService))
+ {
+ return new System.ServiceModel.EndpointAddress("http://localhost:51402/UserService.svc");
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetDefaultBinding()
+ {
+ return UserServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IUserService);
+ }
+
+ private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
+ {
+ return UserServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IUserService);
+ }
+
+ public enum EndpointConfiguration
+ {
+
+ BasicHttpBinding_IUserService,
+ }
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Controllers/LoginController.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/Controllers/LoginController.cs
index 7047cd95..26cb5b19 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/Controllers/LoginController.cs
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Controllers/LoginController.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Tailwind.Traders.WebBff.Infrastructure;
using Tailwind.Traders.WebBff.Models;
+using Tailwind.Traders.WebBff.Services;
namespace Tailwind.Traders.WebBff.Controllers
{
@@ -18,15 +19,18 @@ namespace Tailwind.Traders.WebBff.Controllers
public class LoginController : Controller
{
private readonly IHttpClientFactory _httpClientFactory;
+ private readonly IRegisterService _registerService;
private readonly AppSettings _settings;
private const string VERSION_API = "v1";
public LoginController(
IHttpClientFactory httpClientFactory,
- IOptions options)
+ IOptions options,
+ IRegisterService registerService)
{
_httpClientFactory = httpClientFactory;
_settings = options.Value;
+ _registerService = registerService;
}
// POST: v1/login
@@ -40,10 +44,16 @@ public async Task Login([FromBody] TokenRequest request)
var response = await client.PostAsync(API.Login.PostLogin(_settings.LoginApiUrl, VERSION_API), stringContent);
- if (response.StatusCode == HttpStatusCode.BadRequest) {
+ if (response.StatusCode == HttpStatusCode.BadRequest)
+ {
return BadRequest();
}
+ if (_settings.RegisterUsers)
+ {
+ await _registerService.RegisterUserIfNotExists(request.Username);
+ }
+
var result = await response.Content.ReadAsStringAsync();
var authResponse = JsonConvert.DeserializeObject(result);
return Ok(authResponse);
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Services/IRegisterService.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/Services/IRegisterService.cs
new file mode 100644
index 00000000..d3ff7da7
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Services/IRegisterService.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace Tailwind.Traders.WebBff.Services
+{
+ public interface IRegisterService
+ {
+ Task RegisterUserIfNotExists(string email);
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Services/RegisterService.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/Services/RegisterService.cs
new file mode 100644
index 00000000..31f3e961
--- /dev/null
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Services/RegisterService.cs
@@ -0,0 +1,19 @@
+using RegistrationUserService;
+using System.Threading.Tasks;
+
+namespace Tailwind.Traders.WebBff.Services
+{
+ public class RegisterService : IRegisterService
+ {
+ private readonly IUserService _client;
+
+ public RegisterService(IUserService client)
+ {
+ _client = client;
+ }
+ public async Task RegisterUserIfNotExists(string email)
+ {
+ return await _client.RegistrationAsync(email);
+ }
+ }
+}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Startup.cs b/Source/ApiGWs/Tailwind.Traders.WebBff/Startup.cs
index c2127842..0ec364d9 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/Startup.cs
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Startup.cs
@@ -8,12 +8,16 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Tokens;
+using RegistrationUserService;
using System;
+using System.ServiceModel;
using System.Text;
using System.Threading;
using Tailwind.Traders.WebBff.Helpers;
using Tailwind.Traders.WebBff.Infrastructure;
-
+using Tailwind.Traders.WebBff.Services;
+using static RegistrationUserService.UserServiceClient;
+
namespace Tailwind.Traders.WebBff
{
public class Startup
@@ -32,6 +36,11 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpClientServices(Configuration);
services.Configure(Configuration);
+ services.AddTransient(_ => new UserServiceClient(
+ EndpointConfiguration.BasicHttpBinding_IUserService,
+ new EndpointAddress(Configuration["RegistrationUsersEndpoint"])));
+
+ services.AddTransient();
services.AddSwaggerGen(options =>
{
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/Tailwind.Traders.WebBff.csproj b/Source/ApiGWs/Tailwind.Traders.WebBff/Tailwind.Traders.WebBff.csproj
index 6e3fbeef..41c680d0 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/Tailwind.Traders.WebBff.csproj
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/Tailwind.Traders.WebBff.csproj
@@ -18,6 +18,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.Development.json b/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.Development.json
index 387897fd..7341d13e 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.Development.json
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.Development.json
@@ -17,5 +17,7 @@
"Issuer": "TTFakeLogin",
"UseB2C": "false",
"B2CIssuer": "",
- "Authority": ""
+ "Authority": "",
+ "RegisterUsers": false,
+ "RegistrationUsersEndpoint": "http://localhost:51402/UserService.svc"
}
diff --git a/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.json b/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.json
index 3c69f444..3ab5f085 100644
--- a/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.json
+++ b/Source/ApiGWs/Tailwind.Traders.WebBff/appsettings.json
@@ -9,5 +9,7 @@
"Issuer": "",
"UseB2C": "false",
"B2CIssuer": "",
- "Authority": ""
+ "Authority": "",
+ "RegisterUsers": false,
+ "RegistrationUsersEndpoint": "http://localhost:51402/UserService.svc"
}
diff --git a/Source/Services/Tailwind.Traders.Profile.Api/Controllers/ProfilesController.cs b/Source/Services/Tailwind.Traders.Profile.Api/Controllers/ProfilesController.cs
index 6e49561a..bb695ef5 100644
--- a/Source/Services/Tailwind.Traders.Profile.Api/Controllers/ProfilesController.cs
+++ b/Source/Services/Tailwind.Traders.Profile.Api/Controllers/ProfilesController.cs
@@ -2,10 +2,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
+using Microsoft.Extensions.Primitives;
using System.Collections.Generic;
using System.Linq;
using System.Net;
-using System.Security.Claims;
using System.Threading.Tasks;
using Tailwind.Traders.Profile.Api.DTOs;
using Tailwind.Traders.Profile.Api.Infrastructure;
diff --git a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Dockerfile b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Dockerfile
index c8d8534c..b91ae2b3 100644
--- a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Dockerfile
+++ b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Dockerfile
@@ -1,8 +1,7 @@
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
-
-FROM mcr.microsoft.com/dotnet/framework/wcf:4.7.2-windowsservercore-ltsc2019
-ARG source
+ARG imageTag=4.7.2-windowsservercore-ltsc2019
+FROM mcr.microsoft.com/dotnet/framework/wcf:${imageTag}
EXPOSE 808
WORKDIR /inetpub/wwwroot
-COPY ${source:-obj/Docker/publish} .
+COPY obj/Docker/publish .
diff --git a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Properties/PublishProfiles/FolderProfile.pubxml b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 00000000..2314eb1a
--- /dev/null
+++ b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ FileSystem
+ FileSystem
+ Release
+ Any CPU
+
+ True
+ False
+ obj\Docker\publish
+ False
+
+
\ No newline at end of file
diff --git a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/BaseRepository.cs b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/BaseRepository.cs
index 1dd838bb..7a45344a 100644
--- a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/BaseRepository.cs
+++ b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/BaseRepository.cs
@@ -26,7 +26,7 @@ protected SqlConnection Connection
protected DataTable ExecuteSelect(string query, SqlParameter[] parameters)
{
- DataTable table = null;
+ DataTable table = new DataTable();
using (SqlCommand command = new SqlCommand(query, Connection))
{
if (parameters != null)
diff --git a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/CustomerRepositories.cs b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/CustomerRepositories.cs
index 7914d81b..1172bff5 100644
--- a/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/CustomerRepositories.cs
+++ b/Source/Services/Tailwind.Traders.Rewards.Registration.Api/Repositories/CustomerRepositories.cs
@@ -28,9 +28,26 @@ public Customer GetCustomerByEmailOrName(string emailOrName)
public void InsertCustomer(string email)
{
- var query = "INSERT INTO CUSTOMERS([Email]) VALUES (@email)";
- var emailParam = new SqlParameter("@email", email);
- ExecuteNonSelect(query, new SqlParameter[] { emailParam });
+ var query = @"INSERT INTO CUSTOMERS
+ ([Email],
+ [Active],
+ [Enrrolled]
+ )
+ VALUES
+ (@Email
+ ,@Active
+ ,@Enrrolled)";
+
+
+ var enrollmentStatus = (int)EnrollmentStatusEnum.Uninitialized;
+ var parameters = new SqlParameter[]
+ {
+ new SqlParameter("@Email", email),
+ new SqlParameter("@Active", true),
+ new SqlParameter("@Enrrolled", enrollmentStatus)
+ };
+
+ ExecuteNonSelect(query, parameters);
}
}
}
\ No newline at end of file
diff --git a/Source/docker-compose.override.yml b/Source/docker-compose.override.yml
index ee944cd5..fa9efd2e 100644
--- a/Source/docker-compose.override.yml
+++ b/Source/docker-compose.override.yml
@@ -108,7 +108,7 @@ services:
- SECURITYKEY=nEpLzQJGNSCNL5H6DIQCtTdNxf5VgAGcBbtXLms1YDD01KJBAs0WVawaEjn97uwB
- UseB2C=${UseB2C:-false}
ports:
- - "5007:3001"
+ - "5007:3001"
mobileapigw:
environment:
@@ -120,6 +120,8 @@ services:
- CouponsApiUrl=http://coupon.api
- ImageClassifierApiUrl=http://image-classifier.api
- LoginApiUrl=http://login.api
+ - RegisterUsers=${RegisterUsers:-true}
+ - RegistrationUsersEndpoint=
ports:
- "5100:80"
@@ -140,5 +142,7 @@ services:
- UseB2C=${UseB2C:-false}
- B2CIssuer=
- Authority=
+ - RegisterUsers=${RegisterUsers:-true}
+ - RegistrationUsersEndpoint=
ports:
- "5200:80"
\ No newline at end of file