From bda1e81c87a34bc0e6d2ce805f706a726087e957 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 30 Jan 2022 01:30:58 +0100 Subject: feat: WIP: Map github logins When github is used for login, we want to create a mapping to a regular user in our database. This is mainly so that we don't have to change the PK in our database or add a column to it. --- src/server/Api/Internal/Account/GetClaimsRoute.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/server/Api/Internal/Account/GetClaimsRoute.cs (limited to 'src/server/Api/Internal/Account/GetClaimsRoute.cs') diff --git a/src/server/Api/Internal/Account/GetClaimsRoute.cs b/src/server/Api/Internal/Account/GetClaimsRoute.cs new file mode 100644 index 0000000..fde8887 --- /dev/null +++ b/src/server/Api/Internal/Account/GetClaimsRoute.cs @@ -0,0 +1,16 @@ +namespace IOL.BookmarkThing.Server.Api.Internal.Account; + +public class GetClaimsRoute : RouteBaseInternalSync.WithoutRequest.WithActionResult +{ + [HttpGet("~/v{apiVersion:apiVersion}/account/claims")] + public override ActionResult Handle() { + if (HttpContext.Request.Query.ContainsKey("download")) { + var serializerOptions = new JsonSerializerOptions() { + ReferenceHandler = ReferenceHandler.IgnoreCycles + }; + return File(JsonSerializer.SerializeToUtf8Bytes(User.Claims, serializerOptions), "application/json", "claims_" + User.Identity?.Name + ".json"); + } + + return Ok(User.Claims); + } +} -- cgit v1.3