techgarage-ir.MTWireGuard/Pages/Logout.cshtml.cs

31 lines
1,016 B
C#
Raw Normal View History

2023-03-03 23:24:18 +03:30
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using MTWireGuard.Repositories;
namespace MTWireGuard.Pages
{
public class LogoutModel : PageModel
{
private readonly IMikrotikRepository API;
public LogoutModel(IMikrotikRepository mikrotik)
{
API = mikrotik;
}
public async Task<IActionResult> OnGetAsync(string returnUrl = "Login")
{
// Clear the existing external cookie
await HttpContext.SignOutAsync(
CookieAuthenticationDefaults.AuthenticationScheme);
/*
var sessionId = await MTAPIHandler.GetCurrentSessionID();
var remove = await MTAPIHandler.KillJob(sessionId);*/
var sessionId = await API.GetCurrentSessionID();
var kill = await API.KillJob(sessionId);
return RedirectToPage(returnUrl);
}
}
}