33 lines
848 B
C#
33 lines
848 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Oqtane.Shared;
|
|
|
|
namespace Oqtane.Pages
|
|
{
|
|
[AllowAnonymous]
|
|
public class LogoutModel : PageModel
|
|
{
|
|
public async Task<IActionResult> OnGetAsync(string returnurl)
|
|
{
|
|
if (HttpContext.User.Identity.IsAuthenticated)
|
|
{
|
|
await HttpContext.SignOutAsync(Constants.AuthenticationScheme);
|
|
}
|
|
|
|
if (returnurl == null)
|
|
{
|
|
returnurl = "";
|
|
}
|
|
if (!returnurl.StartsWith("/"))
|
|
{
|
|
returnurl = "/" + returnurl;
|
|
}
|
|
|
|
return LocalRedirect(Url.Content("~" + returnurl));
|
|
}
|
|
}
|
|
}
|