summaryrefslogtreecommitdiffstats
path: root/src/server/Api/V1/BaseV1Route.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-01-30 01:30:58 +0100
committerivarlovlie <git@ivarlovlie.no>2022-01-30 01:30:58 +0100
commitbda1e81c87a34bc0e6d2ce805f706a726087e957 (patch)
tree124ebf09d1289900e0d67d8723528b96bfbb6a7e /src/server/Api/V1/BaseV1Route.cs
parent253c8479b9ae0ba6853a70728d3f6e904e1ac2ba (diff)
downloadbookmark-thing-bda1e81c87a34bc0e6d2ce805f706a726087e957.tar.xz
bookmark-thing-bda1e81c87a34bc0e6d2ce805f706a726087e957.zip
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.
Diffstat (limited to 'src/server/Api/V1/BaseV1Route.cs')
-rw-r--r--src/server/Api/V1/BaseV1Route.cs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/server/Api/V1/BaseV1Route.cs b/src/server/Api/V1/BaseV1Route.cs
index 21c8128..9322bf9 100644
--- a/src/server/Api/V1/BaseV1Route.cs
+++ b/src/server/Api/V1/BaseV1Route.cs
@@ -13,8 +13,8 @@ public class BaseV1Route : ControllerBase
/// User data for the currently logged on user.
/// </summary>
protected LoggedInV1User LoggedInUser => new() {
+ Id = User.FindFirstValue(ClaimTypes.NameIdentifier).ToGuid(),
Username = User.Identity?.Name,
- Id = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value.ToGuid() ?? default
};
protected bool IsApiCall() {
@@ -22,8 +22,7 @@ public class BaseV1Route : ControllerBase
try {
var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]);
if (authHeader.Parameter == null) return false;
- } catch (Exception e) {
- Console.WriteLine(e);
+ } catch {
return false;
}