diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | main.go | 1 | ||||
-rw-r--r-- | pw.go | 52 | ||||
-rw-r--r-- | tmpl/index_login.html | 38 |
4 files changed, 1 insertions, 92 deletions
@@ -1,2 +1,2 @@ -cca: auth.go config.go courses.go db.go index.go main.go pw.go utils.go ws.go +cca: auth.go config.go courses.go db.go index.go main.go utils.go ws.go go build -o cca @@ -75,7 +75,6 @@ func main() { log.Println("Registering handlers") http.HandleFunc("/{$}", handleIndex) http.HandleFunc("/auth", handleAuth) - http.HandleFunc("/pw", handlePw) http.HandleFunc("/ws", handleWs) log.Printf( @@ -1,52 +0,0 @@ -/* - * Password handling - * - * Copyright (C) 2024 Runxi Yu <https://runxiyu.org> - * SPDX-License-Identifier: AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package main - -import ( - "net/http" -) - -/* - * Password-handling is currently unimplemented, but a stub function is here - * for easy implementation when that's needed. - */ -func handlePw(w http.ResponseWriter, req *http.Request) { - if req.Method != http.MethodPost { - wstr(w, http.StatusMethodNotAllowed, "Only POST is supported on the password login endpoint") - return - } - - err := req.ParseForm() - if err != nil { - wstr(w, http.StatusBadRequest, "Malformed form data") - return - } - - username := req.PostFormValue("usernameinput") - password := req.PostFormValue("passwordinput") - - if username == "" || password == "" { - wstr(w, http.StatusBadRequest, "Empty username or password field") - return - } - - wstr(w, http.StatusUnauthorized, "Authentication failed") -} diff --git a/tmpl/index_login.html b/tmpl/index_login.html index 55aeadc..7bf66b6 100644 --- a/tmpl/index_login.html +++ b/tmpl/index_login.html @@ -37,46 +37,8 @@ You have not authenticated. You must sign in to use this service. </p> <p> - Most users should use “Sign in with Microsoft”. - </p> - <p> <a class="btn btn-primary" href="{{- .authURL -}}">Sign in with Microsoft</a> </p> - <p> - Users who have special access may use password authentication. - </p> - <form id="form-auto-token" method="POST" action="/pw" enctype="application/x-www-form-urlencoded"> - <table class=""> - <tr> - <th colspan="2"> - Password-based authentication form - </th> - </tr> - <tr> - <th scope="row">Username</th> - <td class="tdinput"> - <input id="usernameinput" name="usernameinput" placeholder="s12345" type="text" /> - </td> - </tr> - <tr> - <th scope="row">Password</th> - <td class="tdinput"> - <input id="passwordinput" name="passwordinput" type="password" /> - </td> - </tr> - <tr> - <td class="th-like" colspan="2"> - <div class="flex-justify"> - <div class="left"> - </div> - <div class="right"> - <input class="btn-white" type="submit" value="Submit" /> - </div> - </div> - </td> - </tr> - </table> - </form> </div> </main> <footer> |