feat: expose method to delete sid

This commit is contained in:
Oliver Booth 2024-02-25 14:14:32 +00:00
parent 2a16c185fe
commit 9593979d7b
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
2 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,13 @@ public interface ISessionService
/// <exception cref="ArgumentNullException"><paramref name="session" /> is <see langword="null" />.</exception>
void DeleteSession(ISession session);
/// <summary>
/// Deletes the client's session cookie.
/// </summary>
/// <param name="response">The response to edit.</param>
/// <exception cref="ArgumentNullException"><paramref name="response" /> is <see langword="null" />.</exception>
IActionResult DeleteSessionCookie(HttpResponse response);
/// <summary>
/// Saves a session cookie to the client's browser.
/// </summary>

View File

@ -70,6 +70,13 @@ internal sealed class SessionService : BackgroundService, ISessionService
context.SaveChanges();
}
/// <inheritdoc />
public IActionResult DeleteSessionCookie(HttpResponse response)
{
response.Cookies.Delete("sid");
return new RedirectToPageResult("/Admin/Login");
}
/// <inheritdoc />
public void SaveSessionCookie(HttpResponse response, ISession session)
{