Autosubmit mailing list confirmation
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -42,14 +42,17 @@ func confirmGetHandler() http.HandlerFunc {
|
||||
renderPage(
|
||||
w,
|
||||
http.StatusOK,
|
||||
// The confirmation should happen too quickly for the user to notice.
|
||||
// This content is only shown as a fallback.
|
||||
page{
|
||||
Title: "Confirm subscription",
|
||||
Heading: "Confirm your subscription",
|
||||
Body: "Click the button below to confirm that you want to receive updates.",
|
||||
Body: "Your confirmation should be processed automatically. If it isn’t, click the button below to confirm that you want to receive updates.",
|
||||
Form: &form{
|
||||
ActionURL: template.URL("?token=" + url.QueryEscape(token)),
|
||||
Button: "Confirm subscription",
|
||||
Danger: false,
|
||||
ActionURL: template.URL("?token=" + url.QueryEscape(token)),
|
||||
Button: "Confirm subscription",
|
||||
AutoSubmit: true,
|
||||
Danger: false,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -24,9 +24,10 @@ import (
|
||||
var pageTmplHTML string
|
||||
|
||||
type form struct {
|
||||
ActionURL template.URL
|
||||
Button string
|
||||
Danger bool
|
||||
ActionURL template.URL
|
||||
Button string
|
||||
Danger bool
|
||||
AutoSubmit bool
|
||||
}
|
||||
|
||||
type page struct {
|
||||
|
||||
@@ -88,11 +88,14 @@
|
||||
<h1>{{.Heading}}</h1>
|
||||
<p>{{.Body}}</p>
|
||||
{{- if .Form}}
|
||||
<form method="POST" action="{{.Form.ActionURL}}">
|
||||
<form id="action-form" method="POST" action="{{.Form.ActionURL}}">
|
||||
<button type="submit" class="{{if .Form.Danger}}danger{{else}}primary{{end}}">
|
||||
{{.Form.Button}}
|
||||
</button>
|
||||
</form>
|
||||
{{- if .Form.AutoSubmit}}
|
||||
<script>document.getElementById("action-form").submit();</script>
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user