Fix sign in request

This commit is contained in:
Trevor Slocum 2024-10-22 14:39:32 -07:00
parent ae388d7cad
commit 3984afc60b

14
web.go
View file

@ -17,6 +17,16 @@ import (
//go:embed www
var wwwFS embed.FS
var signInPage = []byte(`
<body onload="askToSignIn()">
<script type="text/javascript">
function askToSignIn() {
MA.askToSignIn();
}
</script>
</body>
`)
var pages = map[string]http.HandlerFunc{
"community": handleCommunity,
"sessions": handleSessions,
@ -39,8 +49,8 @@ func authenticateUser(w http.ResponseWriter, r *http.Request) *account {
return nil
} else if acc == nil {
w.Header().Set("x-MediNET", "signin")
w.Header().Set("Location", "/signin")
w.WriteHeader(http.StatusTemporaryRedirect)
w.WriteHeader(http.StatusOK)
w.Write(signInPage)
logDebugf("Asking to sign in %s %q", key, html.EscapeString(r.URL.RequestURI()))
return nil
}