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

22 lines
746 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;
2023-06-02 15:26:29 +03:30
using MTWireGuard.Application.Repositories;
2023-03-03 23:24:18 +03:30
namespace MTWireGuard.Pages
{
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);
var sessionId = await api.GetCurrentSessionID();
var kill = await api.KillJob(sessionId);
2023-03-03 23:24:18 +03:30
return RedirectToPage(returnUrl);
}
}
}