From 24ed3ced207b2be26b4b4c6fe7fa1d03a1ce3812 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Tue, 24 Jan 2023 19:31:00 +0100 Subject: [PATCH] Fix dev environment --- trainav.web/Utils/AuthUtil.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/trainav.web/Utils/AuthUtil.cs b/trainav.web/Utils/AuthUtil.cs index 0b5ab53..4ba29fb 100644 --- a/trainav.web/Utils/AuthUtil.cs +++ b/trainav.web/Utils/AuthUtil.cs @@ -4,14 +4,20 @@ using Microsoft.AspNetCore.Http; using trainav.web.database; using trainav.web.database.Tables; -namespace trainav.web.Utils; +namespace trainav.web.Utils; public static class AuthUtil { public static string GetRemoteUser(HttpContext ctx, Database.DbConn db) { + #if (DEBUG) + const string remoteUser = "zotan"; + #else var remoteUser = ctx.Request.Headers["Remote-User"]; + #endif + if (!db.Users.Any(p => p.Username == remoteUser)) { - db.InsertWithInt32Identity(new User {Username = remoteUser}); + db.InsertWithInt32Identity(new User { Username = remoteUser }); } - return ctx.Request.Headers["Remote-User"]; + + return remoteUser; } }