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;
|
2023-06-02 15:26:29 +03:30
|
|
|
using MTWireGuard.Application.Repositories;
|
2023-03-03 23:24:18 +03:30
|
|
|
|
|
|
|
namespace MTWireGuard.Pages
|
|
|
|
{
|
2024-01-25 20:40:43 +03:30
|
|
|
public class LogoutModel(IMikrotikRepository api) : PageModel
|
2023-03-03 23:24:18 +03:30
|
|
|
{
|
|
|
|
public async Task<IActionResult> OnGetAsync(string returnUrl = "Login")
|
|
|
|
{
|
|
|
|
// Clear the existing external cookie
|
|
|
|
await HttpContext.SignOutAsync(
|
|
|
|
CookieAuthenticationDefaults.AuthenticationScheme);
|
2024-01-25 20:40:43 +03:30
|
|
|
var sessionId = await api.GetCurrentSessionID();
|
|
|
|
var kill = await api.KillJob(sessionId);
|
2023-03-03 23:24:18 +03:30
|
|
|
return RedirectToPage(returnUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|