Compare commits

...

2 commits

Author SHA1 Message Date
Laura Hausmann 24ed3ced20
Fix dev environment 2023-01-24 19:31:00 +01:00
Laura Hausmann 58ee088545
Update dev environment 2023-01-24 19:30:51 +01:00
2 changed files with 10 additions and 4 deletions

View file

@ -3,7 +3,7 @@
"trainav.web": {
"commandName": "Project",
"launchBrowser": false,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "https://localhost:7005",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

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