footer: Add a semi-flexible template system
This commit is contained in:
parent
bda763725e
commit
021fc3cc7e
26 changed files with 239 additions and 208 deletions
|
|
@ -1,3 +1,20 @@
|
|||
{{ template "_form.html" . }}
|
||||
{{ define "form/title" }}Login Required{{ end }}
|
||||
{{ define "form/button" }}Login{{ end }}
|
||||
{{ define "form/inside" }}
|
||||
<div class="pure-form-group">
|
||||
<p>
|
||||
The site you are attempting to access requires you to login with your account.
|
||||
Simply fill out the form below and click <em>Login</em>.
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
This functionality requires you to have cookies enabled.
|
||||
A cookie to prevent fraudulent login attempts has already been set on your machine.
|
||||
When clicking the <em>Login</em> button, a further cookie will be set on your computer to keep track of your login session.
|
||||
If you do not wish to have futher cookie(s) set, do not click Login and do not attempt to access protected sites.
|
||||
See also <a href="/legal/#cookies">Legal Notices</a>.
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
@ -79,7 +79,7 @@ func (panel *UserPanel) UserFormContext(ctx httpx.FormContext, r *http.Request)
|
|||
user, err := panel.Dependencies.Auth.UserOf(r)
|
||||
|
||||
uctx := userFormContext{FormContext: ctx}
|
||||
panel.Dependencies.Custom.Update(&uctx)
|
||||
panel.Dependencies.Custom.Update(&uctx, r)
|
||||
if err == nil {
|
||||
uctx.User = &user.User
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func (panel *UserPanel) routeTOTPEnroll(ctx context.Context) http.Handler {
|
|||
FormContext: context,
|
||||
},
|
||||
}
|
||||
panel.Dependencies.Custom.Update(&ctx.userFormContext)
|
||||
panel.Dependencies.Custom.Update(&ctx.userFormContext, r)
|
||||
|
||||
if err == nil && user != nil {
|
||||
ctx.userFormContext.User = &user.User
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ func (panel *UserPanel) routeUser(ctx context.Context) http.Handler {
|
|||
userTemplate := panel.Dependencies.Custom.Template(userTemplate)
|
||||
return &httpx.HTMLHandler[routeUserContext]{
|
||||
Handler: func(r *http.Request) (ruc routeUserContext, err error) {
|
||||
panel.Dependencies.Custom.Update(&ruc)
|
||||
panel.Dependencies.Custom.Update(&ruc, r)
|
||||
ruc.AuthUser, err = panel.Dependencies.Auth.UserOf(r)
|
||||
return routeUserContext{}, err
|
||||
return ruc, err
|
||||
},
|
||||
Template: userTemplate,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func (auth *Auth) authLogin(ctx context.Context) http.Handler {
|
|||
if context.Err != nil {
|
||||
context.Err = errLoginFailed
|
||||
}
|
||||
httpx.WriteHTML(auth.Dependencies.Custom.NewForm(context), nil, loginTemplate, "", w, r)
|
||||
httpx.WriteHTML(auth.Dependencies.Custom.NewForm(context, r), nil, loginTemplate, "", w, r)
|
||||
},
|
||||
|
||||
Validate: func(r *http.Request, values map[string]string) (*AuthUser, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue