From 0e7e4e41d7f50038b5222ca52cc7e9706e6c1f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ca=C3=B1izares=20Est=C3=A9vez?= Date: Tue, 20 Dec 2016 12:22:28 +0100 Subject: [PATCH] MVC: Solve feedback, improve validations Identity: Solve Microsoft Edge problem Ordering: Remove application tier --- eShopOnContainers.sln | 51 ------------------- .../Basket.API/Properties/launchSettings.json | 2 +- .../Basket/Basket.API/appsettings.json | 2 +- .../Controllers/AccountController.cs | 3 ++ .../Properties/launchSettings.json | 2 +- .../eShopOnContainers.Identity/Startup.cs | 8 +++ .../Ordering/Ordering.API/settings.json | 2 +- src/Web/WebMVC/Controllers/OrderController.cs | 4 +- src/Web/WebMVC/Models/Order.cs | 2 +- src/Web/WebMVC/Services/IdentityParser.cs | 1 + src/Web/WebMVC/Services/OrderingService.cs | 2 +- src/Web/WebMVC/Views/Catalog/Index.cshtml | 4 +- src/Web/WebMVC/Views/Order/Create.cshtml | 1 + src/Web/WebMVC/Views/Order/_OrderItems.cshtml | 5 +- .../Shared/Components/Cart/Default.cshtml | 7 ++- src/Web/WebMVC/appsettings.json | 2 +- src/Web/WebMVC/wwwroot/css/site.css | 14 +++-- 17 files changed, 39 insertions(+), 73 deletions(-) diff --git a/eShopOnContainers.sln b/eShopOnContainers.sln index 9c33cab6f..46d968f4e 100644 --- a/eShopOnContainers.sln +++ b/eShopOnContainers.sln @@ -63,8 +63,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunne EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunner.iOS", "src\Mobile\eShopOnContainers\eShopOnContainers.TestRunner.iOS\eShopOnContainers.TestRunner.iOS.csproj", "{B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Application", "src\Services\Ordering\Ordering.Application\Ordering.Application.xproj", "{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Infrastructure", "src\Services\Ordering\Ordering.Infrastructure\Ordering.Infrastructure.xproj", "{95F1F07C-4D92-4742-BD07-E5B805AAB651}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{02DF7FEE-C302-433D-A6CD-237A2569F236}" @@ -707,54 +705,6 @@ Global {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|x64.ActiveCfg = Release|iPhone {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|x86.ActiveCfg = Release|iPhone - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.ActiveCfg = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.Build.0 = Debug|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.Build.0 = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.Build.0 = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.Build.0 = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.Build.0 = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.ActiveCfg = Release|Any CPU - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.Build.0 = Release|Any CPU {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU @@ -928,7 +878,6 @@ Global {A289A7F0-ACD8-42AE-87B6-AB1AFD310BF1} = {B7B1D395-4E06-4036-BE86-C216756B9367} {02680C26-CA1D-4D9D-A7E3-D66AF5BE6F2F} = {B7B1D395-4E06-4036-BE86-C216756B9367} {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {B7B1D395-4E06-4036-BE86-C216756B9367} - {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} {95F1F07C-4D92-4742-BD07-E5B805AAB651} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} {02DF7FEE-C302-433D-A6CD-237A2569F236} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8} {A579E108-5445-403D-A407-339AC4D1611B} = {02DF7FEE-C302-433D-A6CD-237A2569F236} diff --git a/src/Services/Basket/Basket.API/Properties/launchSettings.json b/src/Services/Basket/Basket.API/Properties/launchSettings.json index 77a30062f..73a5ae0c9 100644 --- a/src/Services/Basket/Basket.API/Properties/launchSettings.json +++ b/src/Services/Basket/Basket.API/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5003/", + "applicationUrl": "http://localhost:5103/", "sslPort": 0 } }, diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index 7ef0fc8df..31f76d0d0 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -7,6 +7,6 @@ "Microsoft": "Information" } }, - "IdentityUrl": "http://identity.service:5105", + "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1" } diff --git a/src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs b/src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs index 467c570ad..63c73d119 100644 --- a/src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs +++ b/src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs @@ -298,7 +298,10 @@ namespace IdentityServer4.Quickstart.UI.Controllers if (HttpContext.User.Identity.IsAuthenticated) return Redirect(returnUrl); else + if (ModelState.IsValid) return RedirectToAction("login", "account", new { returnUrl = returnUrl }); + else + return View(model); } return RedirectToAction("index", "home"); diff --git a/src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json b/src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json index 622822efc..91f06fd57 100644 --- a/src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json +++ b/src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json @@ -3,7 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:5000", + "applicationUrl": "http://localhost:5105", "sslPort": 0 } }, diff --git a/src/Services/Identity/eShopOnContainers.Identity/Startup.cs b/src/Services/Identity/eShopOnContainers.Identity/Startup.cs index 2c9a08521..716c1dbe9 100644 --- a/src/Services/Identity/eShopOnContainers.Identity/Startup.cs +++ b/src/Services/Identity/eShopOnContainers.Identity/Startup.cs @@ -93,6 +93,14 @@ namespace eShopOnContainers.Identity app.UseStaticFiles(); + + // Make work identity server redirections in Edge and lastest versions of browers. WARN: Not valid in a production environment. + app.Use(async (context, next) => + { + context.Response.Headers.Add("Content-Security-Policy", "script-src 'unsafe-inline'"); + await next(); + }); + app.UseIdentity(); // Adds IdentityServer diff --git a/src/Services/Ordering/Ordering.API/settings.json b/src/Services/Ordering/Ordering.API/settings.json index ea67d33a8..a6c3d9cac 100644 --- a/src/Services/Ordering/Ordering.API/settings.json +++ b/src/Services/Ordering/Ordering.API/settings.json @@ -1,6 +1,6 @@ { "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;", - "IdentityUrl": "http://identity.service:5105", + "IdentityUrl": "http://localhost:5105", "Logging": { "IncludeScopes": false, "LogLevel": { diff --git a/src/Web/WebMVC/Controllers/OrderController.cs b/src/Web/WebMVC/Controllers/OrderController.cs index 646349de9..8f1d1d612 100644 --- a/src/Web/WebMVC/Controllers/OrderController.cs +++ b/src/Web/WebMVC/Controllers/OrderController.cs @@ -37,9 +37,9 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers [HttpPost] public async Task Create(Order model, string action) { - var user = _appUserParser.Parse(HttpContext.User); - if (action == "[ Place Order ]") + if (ModelState.IsValid) { + var user = _appUserParser.Parse(HttpContext.User); await _orderSvc.CreateOrder(model); //Empty basket for current user. diff --git a/src/Web/WebMVC/Models/Order.cs b/src/Web/WebMVC/Models/Order.cs index 368526141..a01bf9519 100644 --- a/src/Web/WebMVC/Models/Order.cs +++ b/src/Web/WebMVC/Models/Order.cs @@ -37,7 +37,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Models public DateTime CardExpiration { get; set; } [RegularExpression(@"(0[1-9]|1[0-2])\/[0-9]{2}", ErrorMessage = "Expiration should match a valid MM/YY value")] - [CardExpiration(ErrorMessage = "Should't be expired"), Required] + [CardExpiration(ErrorMessage = "The card is expired"), Required] public string CardExpirationShort { get; set; } [Required] public string CardSecurityNumber { get; set; } diff --git a/src/Web/WebMVC/Services/IdentityParser.cs b/src/Web/WebMVC/Services/IdentityParser.cs index 5cef8b4cd..d60e69115 100644 --- a/src/Web/WebMVC/Services/IdentityParser.cs +++ b/src/Web/WebMVC/Services/IdentityParser.cs @@ -17,6 +17,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services user.CardHolderName = (claims.Claims.Where(x => x.Type == "card_holder").Count() > 0) ? claims.Claims.First(x => x.Type == "card_holder").Value : ""; user.CardNumber = (claims.Claims.Where(x => x.Type == "card_number").Count() > 0) ? claims.Claims.First(x => x.Type == "card_number").Value : ""; + user.Expiration = (claims.Claims.Where(x => x.Type == "card_expiration").Count() > 0) ? claims.Claims.First(x => x.Type == "card_expiration").Value : ""; user.CardType = (claims.Claims.Where(x => x.Type == "missing").Count() > 0) ? int.Parse(claims.Claims.First(x => x.Type == "missing").Value) : 0; user.City = (claims.Claims.Where(x => x.Type == "address_city").Count() > 0) ? claims.Claims.First(x => x.Type == "address_city").Value : ""; user.Country = (claims.Claims.Where(x => x.Type == "address_country").Count() > 0) ? claims.Claims.First(x => x.Type == "address_country").Value : ""; diff --git a/src/Web/WebMVC/Services/OrderingService.cs b/src/Web/WebMVC/Services/OrderingService.cs index 81fe311a4..70f14072b 100644 --- a/src/Web/WebMVC/Services/OrderingService.cs +++ b/src/Web/WebMVC/Services/OrderingService.cs @@ -65,7 +65,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services order.CardNumber = user.CardNumber; order.CardHolderName = user.CardHolderName; - order.CardExpiration = new DateTime(1,int.Parse(user.Expiration.Split('/')[0]), int.Parse("20" + user.Expiration.Split('/')[1])); + order.CardExpiration = new DateTime(int.Parse("20" + user.Expiration.Split('/')[1]),int.Parse(user.Expiration.Split('/')[0]), 1); order.CardSecurityNumber = user.SecurityNumber; return order; diff --git a/src/Web/WebMVC/Views/Catalog/Index.cshtml b/src/Web/WebMVC/Views/Catalog/Index.cshtml index cc2223b33..71e4e740c 100644 --- a/src/Web/WebMVC/Views/Catalog/Index.cshtml +++ b/src/Web/WebMVC/Views/Catalog/Index.cshtml @@ -12,11 +12,11 @@
- +
- +
+

SHIPPING ADDRESS

diff --git a/src/Web/WebMVC/Views/Order/_OrderItems.cshtml b/src/Web/WebMVC/Views/Order/_OrderItems.cshtml index ec76df224..848737cf9 100644 --- a/src/Web/WebMVC/Views/Order/_OrderItems.cshtml +++ b/src/Web/WebMVC/Views/Order/_OrderItems.cshtml @@ -55,15 +55,12 @@ -
TOTAL
$ @Model.Total +
diff --git a/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml b/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml index 698eb3e9f..32960e5ed 100644 --- a/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml +++ b/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml @@ -6,11 +6,10 @@
- +
+ @Model.ItemsCount +
-
- @Model.ItemsCount -
diff --git a/src/Web/WebMVC/appsettings.json b/src/Web/WebMVC/appsettings.json index 90021dfe4..9fe15aa25 100644 --- a/src/Web/WebMVC/appsettings.json +++ b/src/Web/WebMVC/appsettings.json @@ -2,7 +2,7 @@ "CatalogUrl": "http://localhost:5101", "OrderingUrl": "http://localhost:5102", "BasketUrl": "http://localhost:5103", - "IdentityUrl": "http://identity.service:5105", + "IdentityUrl": "http://localhost:5105", "CallBackUrl": "http://localhost:5100/", "Logging": { "IncludeScopes": false, diff --git a/src/Web/WebMVC/wwwroot/css/site.css b/src/Web/WebMVC/wwwroot/css/site.css index 85cdd1670..7981b10ab 100644 --- a/src/Web/WebMVC/wwwroot/css/site.css +++ b/src/Web/WebMVC/wwwroot/css/site.css @@ -36,7 +36,7 @@ textarea { } .select-filter { - background-color: transparent; + background-color: #00A69C; padding: 10px; margin: 10px; margin-right: 20px; @@ -61,6 +61,7 @@ select::-ms-expand { z-index: 0; display:inline-block; margin-left: -10px; + position:relative } .select-filter-wrapper::before { @@ -75,11 +76,18 @@ select::-ms-expand { color: white; } -.select-filter-arrow { +.select-filter-arrow-container { + position: absolute; + top: 15px; + right: 25px; +} + + +/*.select-filter-arrow { position: absolute; margin-left: 130px; margin-top: 40px; -} +}*/ .btn-brand-small-filter { margin-top: 10px;