summaryrefslogtreecommitdiff
path: root/VPNAuth.Server/Pages
diff options
context:
space:
mode:
Diffstat (limited to 'VPNAuth.Server/Pages')
-rw-r--r--VPNAuth.Server/Pages/Dashboard.cshtml57
1 files changed, 50 insertions, 7 deletions
diff --git a/VPNAuth.Server/Pages/Dashboard.cshtml b/VPNAuth.Server/Pages/Dashboard.cshtml
index cb00d9f..38f9c7e 100644
--- a/VPNAuth.Server/Pages/Dashboard.cshtml
+++ b/VPNAuth.Server/Pages/Dashboard.cshtml
@@ -1,13 +1,20 @@
@page "/"
-@using Microsoft.EntityFrameworkCore.ChangeTracking
@using VPNAuth.Server
@using VPNAuth.Server.Database
@{
Layout = null;
-
+
string remoteIp = Request.HttpContext.GetRemoteIpAddress();
- ConfigUser? user = Request.HttpContext.GetUser();
+ ConfigUser? configUser = Request.HttpContext.GetUser();
+
+ UserInformation? dbUser = null;
+
+ if (configUser != null)
+ {
+ using var db = new Database();
+ dbUser = db.UserInformation.Where(user => user.Sub == configUser!.Username).ToList().FirstOrDefault();
+ }
}
<!DOCTYPE html>
@@ -17,7 +24,7 @@
<title>VPNAuth - Dashboard</title>
</head>
<body style="text-align: center;">
- @if (user == null)
+ @if (configUser == null)
{
<p>No user detected</p>
}
@@ -26,16 +33,52 @@
<div>
<h1>Dashboard</h1>
<h2>VPNAuth</h2>
- <p>Hey, @user.Username!</p>
- <i>User settings coming soon...</i>
+ <p>Hey, @configUser.Username!</p>
+ <h3>User settings</h3>
+ <form hx-post="/user-info" hx-swap="none" hx-trigger="change">
+ <table style="margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <th>Username</th>
+ <th style="text-align: left; font-weight: normal;">@dbUser?.Sub</th>
+ </tr>
+ <tr>
+ <th><label for="given-name">Given name</label></th>
+ <th><input name="given-name" id="given-name" type="text"
+ value="@dbUser?.GivenName"/></th>
+ </tr>
+ <tr>
+ <th><label for="family-name">Family name</label></th>
+ <th><input name="family-name" id="family-name" type="text"
+ value="@dbUser?.FamilyName"/></th>
+ </tr>
+ <tr>
+ <th><label for="preferred-username">Preferred username</label></th>
+ <th><input name="preferred-username" id="preferred-username" type="text"
+ value="@dbUser?.PreferredUsername"/></th>
+ </tr>
+ <tr>
+ <th><label for="email">Email</label></th>
+ <th><input name="email" id="email" type="email"
+ value="@dbUser?.Email"/></th>
+ </tr>
+ <tr>
+ <th><label for="email">Picture URL</label></th>
+ <th><input name="picture" id="picture" type="url"
+ value="@dbUser?.Picture"/></th>
+ </tr>
+ </tbody>
+ </table>
+ </form>
<h3>Your IPs</h3>
<ul style="list-style-position: inside;">
- @foreach (var ip in user.Ips!)
+ @foreach (var ip in configUser.Ips!)
{
<li>@ip</li>
}
</ul>
</div>
}
+ <script src="/static/htmx.js"></script>
</body>
</html>