aboutsummaryrefslogtreecommitdiff
path: root/VPNAuth.Server/Pages/Dashboard.cshtml
blob: f0fea842b2a7a833358b67f1f3d19b765f45cfaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@page "/"
@using VPNAuth.Server
@using VPNAuth.Server.Database

@{
    Layout = null;

    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>

<html>
<head>
    <title>VPNAuth - Dashboard</title>
    <link rel="stylesheet" href="/static/style.css">
</head>
<body>
    @if (configUser == null)
    {
        <p>No user detected with IP <code>@Request.HttpContext.GetRemoteIpAddress()</code>.</p>
    }
    else
    {
        <div>
            <h1>User settings</h1>
            <form hx-post="/user-info-settings" hx-swap="none" hx-trigger="change">
                <table>
                    <tbody>
                        <tr>
                            <th>Username</th>
                            <th class="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>
                        <tr>
                            <th>IPs</th>
                            <th class="normal">
                                <ul>
                                    @foreach (var ip in configUser.Ips!)
                                    {
                                        <li>@ip</li>
                                    }
                                </ul>
                            </th>
                        </tr>
                    </tbody>
                </table>
            </form>
        </div>
    }
    
    <footer>
        <p style="margin-top: 5em;"><a target="_blank" href="https://bytim.eu/projects/VPNAuth/">VPNAuth</a> by Tim</p>
    </footer>
    <script src="/static/htmx.js"></script>
</body>
</html>