Skip to content

Commit e4d3c66

Browse files
author
Carlos Cañizares Estévez
committed
Logout fix for Xamarin in identity
1 parent 10f3e17 commit e4d3c66

7 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
1717
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
1818
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
19-
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
19+
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
2020
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
2121
<NuGetPackageImportStamp>
2222
</NuGetPackageImportStamp>

src/Services/Identity/eShopOnContainers.Identity/Controllers/AccountController.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,11 @@ public async Task<IActionResult> Logout(string logoutId)
156156
return await Logout(new LogoutViewModel { LogoutId = logoutId });
157157
}
158158

159+
//Test for Xamarin.
159160
var context = await _interaction.GetLogoutContextAsync(logoutId);
160161
if (context?.ShowSignoutPrompt == false)
161162
{
162-
// it's safe to automatically sign-out
163+
//it's safe to automatically sign-out
163164
return await Logout(new LogoutViewModel { LogoutId = logoutId });
164165
}
165166

@@ -169,7 +170,6 @@ public async Task<IActionResult> Logout(string logoutId)
169170
{
170171
LogoutId = logoutId
171172
};
172-
173173
return View(vm);
174174
}
175175

@@ -211,9 +211,21 @@ public async Task<IActionResult> Logout(LogoutViewModel model)
211211

212212
// get context information (client name, post logout redirect URI and iframe for federated signout)
213213
var logout = await _interaction.GetLogoutContextAsync(model.LogoutId);
214+
214215
return Redirect(logout?.PostLogoutRedirectUri);
215216
}
216217

218+
public async Task<IActionResult> DeviceLogOut(string redirectUrl)
219+
{
220+
// delete authentication cookie
221+
await HttpContext.Authentication.SignOutAsync();
222+
223+
// set this so UI rendering sees an anonymous user
224+
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
225+
226+
return Redirect(redirectUrl);
227+
}
228+
217229
/// <summary>
218230
/// initiate roundtrip to external authentication provider
219231
/// </summary>

src/Services/Identity/eShopOnContainers.Identity/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public HomeController(IIdentityServerInteractionService interaction, IOptions<Ap
2424

2525
public IActionResult Index(string returnUrl)
2626
{
27-
if (returnUrl != "")
28-
return Redirect(_settings.Value.MvcClient);
29-
3027
return View();
3128
}
3229

src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public OrdersController(IMediator mediator, IOrderQueries orderQueries)
3838
public async Task<IActionResult> AddOrder([FromBody]NewOrderRequest order)
3939
{
4040
if (order.CardExpiration == DateTime.MinValue)
41-
order.CardExpiration = DateTime.Now;
41+
order.CardExpiration = DateTime.Now.AddYears(5);
42+
43+
if (order.CardTypeId == 0)
44+
order.CardTypeId = 1;
4245

4346
order.Buyer = GetUserName();
4447

src/Web/WebMVC/ViewComponents/Cart.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ private async Task<int> ItemsInCartAsync(ApplicationUser user)
3131
{
3232
var basket = await _cartSvc.GetBasket(user);
3333
return basket.Items.Count;
34-
return await Task<int>.Run(()=> { return 0; });
3534
}
3635
}
3736
}

src/Web/WebSPA/eShopOnContainers.WebSPA/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void Main(string[] args)
1818
.UseConfiguration(config)
1919
.UseContentRoot(Directory.GetCurrentDirectory())
2020
.UseIISIntegration()
21-
.UseUrls("http://localhost:5104/")
21+
//.UseUrls("http://localhost:5104/")
2222
.UseStartup<Startup>()
2323
.Build();
2424

src/Web/WebSPA/eShopOnContainers.WebSPA/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"windowsAuthentication": false,
44
"anonymousAuthentication": true,
55
"iisExpress": {
6-
"applicationUrl": "http://localhost:1250/",
6+
"applicationUrl": "http://localhost:5104/",
77
"sslPort": 0
88
}
99
},

0 commit comments

Comments
 (0)