Include styles on login page

This commit is contained in:
Anders Pitman 2020-10-11 14:10:30 -06:00
parent e4c3379ed2
commit d04804e8ac
4 changed files with 36 additions and 10 deletions

View File

@ -11,12 +11,6 @@
<style> <style>
{{.Styles}} {{.Styles}}
.dialog {
margin: 20px;
padding: 20px;
font-size: 18px;
border: 1px solid black;
}
</style> </style>

View File

@ -8,13 +8,21 @@
<link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAAAAACwAAAAAAQABAAACASgAOw=="> <link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAAAAACwAAAAAAQABAAACASgAOw==">
<style>
{{.Styles}}
button {
display: block;
}
</style>
</head> </head>
<body> <body>
<form action="/login" method="post"> <form class='dialog' action="/login" method="post">
<label for="mail">E-mail:</label> <label for="mail">E-mail:</label>
<input type="email" id="mail" name="email"> <input type="email" id="mail" name="email">
<button type="submit">Login</button> <button class='button green-button' type="submit">Login</button>
</form> </form>
</body> </body>
</html> </html>

View File

@ -79,6 +79,13 @@ main {
justify-content: center; justify-content: center;
} }
.dialog {
margin: 20px;
padding: 20px;
font-size: 18px;
border: 1px solid black;
}
.tunnel-list { .tunnel-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -29,6 +29,10 @@ type ConfirmData struct {
CancelUrl string CancelUrl string
} }
type LoginData struct {
Styles template.CSS
}
func NewWebUiHandler(config *BoringProxyConfig, db *Database, auth *Auth, tunMan *TunnelManager) *WebUiHandler { func NewWebUiHandler(config *BoringProxyConfig, db *Database, auth *Auth, tunMan *TunnelManager) *WebUiHandler {
return &WebUiHandler{ return &WebUiHandler{
config, config,
@ -62,7 +66,7 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
token, err := extractToken("access_token", r) token, err := extractToken("access_token", r)
if err != nil { if err != nil {
loginTemplate, err := box.String("login.tmpl") loginTemplateStr, err := box.String("login.tmpl")
if err != nil { if err != nil {
log.Println(err) log.Println(err)
w.WriteHeader(500) w.WriteHeader(500)
@ -70,8 +74,21 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
return return
} }
loginTemplate, err := template.New("test").Parse(loginTemplateStr)
if err != nil {
w.WriteHeader(500)
log.Println(err)
io.WriteString(w, "Error compiling login.tmpl")
return
}
loginData := LoginData{
Styles: template.CSS(stylesText),
}
w.WriteHeader(401) w.WriteHeader(401)
io.WriteString(w, loginTemplate) loginTemplate.Execute(w, loginData)
return return
} }