Compare commits
2 commits
ec1a9a5216
...
24ed3ced20
Author | SHA1 | Date | |
---|---|---|---|
Laura Hausmann | 24ed3ced20 | ||
Laura Hausmann | 58ee088545 |
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue