Adding login form and handler
This commit is contained in:
parent
2b6449f61b
commit
a6d9a99241
3 changed files with 8 additions and 2 deletions
|
|
@ -12,7 +12,7 @@
|
|||
<label for="password">Password</label>
|
||||
<input type="password" name="password" id="password">
|
||||
|
||||
<button onclick="login">Login</button>
|
||||
<button onclick="login()">Login</button>
|
||||
</div>
|
||||
<script src="/login.js"></script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ function login() {
|
|||
const usernameInput = document.getElementById('username');
|
||||
const passwordInput = document.getElementById('password');
|
||||
|
||||
const token = btoa(`${usernameInput.textContent}:${passwordInput.textContent}`);
|
||||
const token = btoa(`${usernameInput.value}:${passwordInput.value}`);
|
||||
document.cookie = `token=${String(token)}; path=/`;
|
||||
}
|
||||
|
|
@ -158,6 +158,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case r.Method == "GET" && r.URL.Path == "/rsvps_list":
|
||||
getStaticFile("./client/rsvps_list.html", "text/html", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/login":
|
||||
getStaticFile("./client/login.html", "text/html", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/index.js":
|
||||
getStaticFile("./client/index.js", "text/javascript", w)
|
||||
|
||||
|
|
@ -167,6 +170,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case r.Method == "GET" && r.URL.Path == "/rsvps_list.js":
|
||||
getStaticFile("./client/rsvps_list.js", "text/javascript", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/login.js":
|
||||
getStaticFile("./client/login.js", "text/javascript", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/style.css":
|
||||
getStaticFile("./client/style.css", "text/css", w)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue