2021-10-24 00:23:45 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
2021-10-24 20:15:09 +01:00
|
|
|
using Selector.Model;
|
|
|
|
|
2021-10-24 00:23:45 +01:00
|
|
|
namespace Selector.Web.Areas.Identity.Pages.Account
|
|
|
|
{
|
|
|
|
[AllowAnonymous]
|
|
|
|
public class LogoutModel : PageModel
|
|
|
|
{
|
2021-10-24 20:15:09 +01:00
|
|
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
2021-10-24 00:23:45 +01:00
|
|
|
private readonly ILogger<LogoutModel> _logger;
|
|
|
|
|
2021-10-24 20:15:09 +01:00
|
|
|
public LogoutModel(SignInManager<ApplicationUser> signInManager, ILogger<LogoutModel> logger)
|
2021-10-24 00:23:45 +01:00
|
|
|
{
|
|
|
|
_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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|