committed by
GitHub
5 changed files with 55 additions and 7 deletions
@ -0,0 +1,10 @@ |
|||
@page |
|||
@model LogoutModel |
|||
@{ |
|||
ViewData["Title"] = "Log out"; |
|||
} |
|||
|
|||
<header> |
|||
<h1>@ViewData["Title"]</h1> |
|||
<p>You have successfully logged out of the application.</p> |
|||
</header> |
|||
@ -0,0 +1,41 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
using Microsoft.eShopWeb.Infrastructure.Identity; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Microsoft.eShopWeb.Web.Areas.Identity.Pages.Account |
|||
{ |
|||
[AllowAnonymous] |
|||
public class LogoutModel : PageModel |
|||
{ |
|||
private readonly SignInManager<ApplicationUser> _signInManager; |
|||
private readonly ILogger<LogoutModel> _logger; |
|||
|
|||
public LogoutModel(SignInManager<ApplicationUser> signInManager, ILogger<LogoutModel> logger) |
|||
{ |
|||
_signInManager = signInManager; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public void OnGet() |
|||
{ |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPost(string returnUrl = null) |
|||
{ |
|||
await _signInManager.SignOutAsync(); |
|||
_logger.LogInformation("User logged out."); |
|||
if (returnUrl != null) |
|||
{ |
|||
return LocalRedirect(returnUrl); |
|||
} |
|||
else |
|||
{ |
|||
return RedirectToPage("/Index"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue