Fix dev environment

This commit is contained in:
Laura Hausmann 2023-01-24 19:31:00 +01:00
parent 58ee088545
commit 24ed3ced20
Signed by: zotan
GPG Key ID: D044E84C5BE01605
1 changed files with 9 additions and 3 deletions

View File

@ -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;
}
}