Browse Source

Logout fix for Xamarin in identity

pull/49/merge
Carlos Cañizares Estévez 8 years ago
parent
commit
e4d3c66d27
7 changed files with 21 additions and 10 deletions
  1. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj
  2. +14
    -2
      src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs
  3. +0
    -3
      src/Services/Identity/eShopOnContainers.Identity/Controllers/HomeController.cs
  4. +4
    -1
      src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs
  5. +0
    -1
      src/Web/WebMVC/ViewComponents/Cart.cs
  6. +1
    -1
      src/Web/WebSPA/eShopOnContainers.WebSPA/Program.cs
  7. +1
    -1
      src/Web/WebSPA/eShopOnContainers.WebSPA/Properties/launchSettings.json

+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj View File

@ -16,7 +16,7 @@
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>


+ 14
- 2
src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs View File

@ -156,10 +156,11 @@ namespace IdentityServer4.Quickstart.UI.Controllers
return await Logout(new LogoutViewModel { LogoutId = logoutId }); return await Logout(new LogoutViewModel { LogoutId = logoutId });
} }
//Test for Xamarin.
var context = await _interaction.GetLogoutContextAsync(logoutId); var context = await _interaction.GetLogoutContextAsync(logoutId);
if (context?.ShowSignoutPrompt == false) if (context?.ShowSignoutPrompt == false)
{ {
// it's safe to automatically sign-out
//it's safe to automatically sign-out
return await Logout(new LogoutViewModel { LogoutId = logoutId }); return await Logout(new LogoutViewModel { LogoutId = logoutId });
} }
@ -169,7 +170,6 @@ namespace IdentityServer4.Quickstart.UI.Controllers
{ {
LogoutId = logoutId LogoutId = logoutId
}; };
return View(vm); return View(vm);
} }
@ -211,9 +211,21 @@ namespace IdentityServer4.Quickstart.UI.Controllers
// get context information (client name, post logout redirect URI and iframe for federated signout) // get context information (client name, post logout redirect URI and iframe for federated signout)
var logout = await _interaction.GetLogoutContextAsync(model.LogoutId); var logout = await _interaction.GetLogoutContextAsync(model.LogoutId);
return Redirect(logout?.PostLogoutRedirectUri); return Redirect(logout?.PostLogoutRedirectUri);
} }
public async Task<IActionResult> DeviceLogOut(string redirectUrl)
{
// delete authentication cookie
await HttpContext.Authentication.SignOutAsync();
// set this so UI rendering sees an anonymous user
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
return Redirect(redirectUrl);
}
/// <summary> /// <summary>
/// initiate roundtrip to external authentication provider /// initiate roundtrip to external authentication provider
/// </summary> /// </summary>


+ 0
- 3
src/Services/Identity/eShopOnContainers.Identity/Controllers/HomeController.cs View File

@ -24,9 +24,6 @@ namespace IdentityServer4.Quickstart.UI.Controllers
public IActionResult Index(string returnUrl) public IActionResult Index(string returnUrl)
{ {
if (returnUrl != "")
return Redirect(_settings.Value.MvcClient);
return View(); return View();
} }


+ 4
- 1
src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs View File

@ -38,7 +38,10 @@
public async Task<IActionResult> AddOrder([FromBody]NewOrderRequest order) public async Task<IActionResult> AddOrder([FromBody]NewOrderRequest order)
{ {
if (order.CardExpiration == DateTime.MinValue) if (order.CardExpiration == DateTime.MinValue)
order.CardExpiration = DateTime.Now;
order.CardExpiration = DateTime.Now.AddYears(5);
if (order.CardTypeId == 0)
order.CardTypeId = 1;
order.Buyer = GetUserName(); order.Buyer = GetUserName();


+ 0
- 1
src/Web/WebMVC/ViewComponents/Cart.cs View File

@ -31,7 +31,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
{ {
var basket = await _cartSvc.GetBasket(user); var basket = await _cartSvc.GetBasket(user);
return basket.Items.Count; return basket.Items.Count;
return await Task<int>.Run(()=> { return 0; });
} }
} }
} }

+ 1
- 1
src/Web/WebSPA/eShopOnContainers.WebSPA/Program.cs View File

@ -18,7 +18,7 @@ namespace eShopConContainers.WebSPA
.UseConfiguration(config) .UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.UseUrls("http://localhost:5104/")
//.UseUrls("http://localhost:5104/")
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();


+ 1
- 1
src/Web/WebSPA/eShopOnContainers.WebSPA/Properties/launchSettings.json View File

@ -3,7 +3,7 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:1250/",
"applicationUrl": "http://localhost:5104/",
"sslPort": 0 "sslPort": 0
} }
}, },


Loading…
Cancel
Save