Added auth
This commit is contained in:
@@ -6,12 +6,50 @@
|
||||
<title>{{ template "title" . }}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
background: #111;
|
||||
color: #eee;
|
||||
padding: 20px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
nav {
|
||||
background-color: #222;
|
||||
border-bottom: 1px solid #444;
|
||||
padding: 5px 0;
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: inline-flex;
|
||||
gap: 15px;
|
||||
}
|
||||
nav li {
|
||||
display: inline;
|
||||
}
|
||||
nav a {
|
||||
color: #0af;
|
||||
text-decoration: none;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid transparent;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
}
|
||||
nav a:hover {
|
||||
background-color: #0af;
|
||||
color: #111;
|
||||
border-color: #0af;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin: auto;
|
||||
@@ -46,23 +84,32 @@
|
||||
color: #0af;
|
||||
text-decoration: none;
|
||||
}
|
||||
li {
|
||||
display: inline;
|
||||
margin: 0 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/shares">View Shares</a></li>
|
||||
<li><a href="/top-shares">Top Shares</a></li>
|
||||
<li><a href="/daily-stats">Daily Stats</a></li>
|
||||
</ul>
|
||||
|
||||
{{ if .UserName }}
|
||||
<ul>
|
||||
<li>{{ .UserName }}</li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
</ul>
|
||||
{{ else }}
|
||||
<ul>
|
||||
<li><a href="/login">Login</a></li>
|
||||
</ul>
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
||||
<h1>{{ template "header" . }}</h1>
|
||||
|
||||
{{ template "content" . }} {{ template "navigation" . }}
|
||||
{{ template "content" . }}
|
||||
</body>
|
||||
</html>
|
||||
{{ end }} {{ define "navigation" }}
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/shares">View Shares</a></li>
|
||||
<li><a href="/top-shares">Top Shares</a></li>
|
||||
<li><a href="/daily-stats">Daily Stats</a></li>
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
61
templates/login.html
Normal file
61
templates/login.html
Normal file
@@ -0,0 +1,61 @@
|
||||
{{ define "title" }}Login{{ end }} {{ define "header" }}🔒 Login{{ end }} {{
|
||||
define "content" }}
|
||||
<style>
|
||||
.login-form {
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
padding: 20px 25px;
|
||||
background-color: #1a1a1a;
|
||||
border: 1px solid #444;
|
||||
color: #eee;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.login-form label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #ccc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.login-form input[type="password"],
|
||||
.login-form input[type="submit"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-bottom: 12px;
|
||||
border: 1px solid #444;
|
||||
background-color: #222;
|
||||
color: #eee;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.login-form input[type="submit"] {
|
||||
background-color: #0af;
|
||||
color: #111;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.login-form input[type="submit"]:hover {
|
||||
background-color: #08c;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #ff6b6b;
|
||||
font-size: 0.9em;
|
||||
margin-top: -8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<form method="POST" action="/login" class="login-form">
|
||||
<label for="password">Password</label><br />
|
||||
<input type="password" id="password" name="password" required /><br /><br />
|
||||
<input type="submit" value="Login" />
|
||||
{{ if .ErrorMessage }}
|
||||
<p class="error">{{ .ErrorMessage }}</p>
|
||||
{{ end }}
|
||||
</form>
|
||||
|
||||
{{ end }} {{ template "layout" . }}
|
||||
Reference in New Issue
Block a user