aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Endpoints/Internal/Account/DeleteAccountRoute.cs
blob: f487f74ec5b6b5868defb302c78bc05a7bc64fd0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace IOL.GreatOffice.Api.Endpoints.Internal.Account;

public class DeleteAccountRoute : RouteBaseAsync.WithoutRequest.WithActionResult
{
    private readonly UserService _userService;

    public DeleteAccountRoute(UserService userService) {
        _userService = userService;
    }

    [HttpDelete("~/_/account/delete")]
    public override async Task<ActionResult> HandleAsync(CancellationToken cancellationToken = default) {
        await _userService.LogOutUser(HttpContext, cancellationToken);
        await _userService.MarkUserAsDeleted(LoggedInUser.Id, LoggedInUser.Id);
        return Ok();
    }
}