From 88110f536f9c3843ecf5016122e101f8a424af77 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 22 Jan 2022 22:43:38 +0100 Subject: Initial commit --- .../Api/Internal/Account/DeleteTokenRoute.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/server/Api/Internal/Account/DeleteTokenRoute.cs (limited to 'src/server/Api/Internal/Account/DeleteTokenRoute.cs') diff --git a/src/server/Api/Internal/Account/DeleteTokenRoute.cs b/src/server/Api/Internal/Account/DeleteTokenRoute.cs new file mode 100644 index 0000000..f423b6f --- /dev/null +++ b/src/server/Api/Internal/Account/DeleteTokenRoute.cs @@ -0,0 +1,24 @@ +namespace IOL.BookmarkThing.Server.Api.Internal.Account; + +public class DeleteTokenRoute : RouteBaseInternalSync.WithRequest.WithActionResult +{ + private readonly AppDbContext _context; + + public DeleteTokenRoute(AppDbContext context) { + _context = context; + } + + [ApiVersionNeutral] + [ApiExplorerSettings(IgnoreApi = true)] + [HttpDelete("~/v{version:apiVersion}/account/delete-token")] + public override ActionResult Handle(Guid id) { + var token = _context.AccessTokens.SingleOrDefault(c => c.Id == id); + if (token == default) { + return NotFound(); + } + + _context.AccessTokens.Remove(token); + _context.SaveChanges(); + return Ok(); + } +} -- cgit v1.3