commit 12988da431cf056831309b903c14c5fff8ce6fa4
parent d6775ea980517e0401394f261c71af464fc27f42
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Wed, 22 May 2024 11:21:36 +0200
allow to dropship public zone key for registration
Diffstat:
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/pkg/rest/gnsregistrar.go b/pkg/rest/gnsregistrar.go
@@ -226,8 +226,9 @@ func (t *Registrar) landingPage(w http.ResponseWriter, r *http.Request) {
fullData := map[string]interface{}{
"suffixHint": t.SuffixHint,
+ "extZkey": r.URL.Query().Get("zkey"),
"zoneKey": t.RootZoneKey,
- "error": r.URL.Query().Get("error"),
+ "error": r.URL.Query().Get("error"),
}
err := t.LandingTpl.Execute(w, fullData)
if err != nil {
@@ -267,6 +268,7 @@ func (t *Registrar) isNameValid(label string) (err error) {
func (t *Registrar) searchPage(w http.ResponseWriter, r *http.Request) {
var (
label string
+ zkey string
err error
)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -276,7 +278,12 @@ func (t *Registrar) searchPage(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, fmt.Sprintf("/?error=%s", err), http.StatusSeeOther)
return
}
- http.Redirect(w, r, "/name/" + url.QueryEscape(label), http.StatusSeeOther)
+ zkey = r.URL.Query().Get("zkey")
+ if "" == zkey {
+ http.Redirect(w, r, "/name/" + url.QueryEscape(label), http.StatusSeeOther)
+ } else {
+ http.Redirect(w, r, "/name/" + url.QueryEscape(label) + "?zkey=" + url.QueryEscape(zkey), http.StatusSeeOther)
+ }
return
}
@@ -928,6 +935,7 @@ func (t *Registrar) namePage(w http.ResponseWriter, r *http.Request) {
fullData := map[string]interface{}{
"label": sanitizedLabel,
"error": r.URL.Query().Get("error"),
+ "zkey": r.URL.Query().Get("zkey"),
"cost": cost,
"available": regMetadata == nil,
"currentValue": value,
diff --git a/web/templates/landing.html b/web/templates/landing.html
@@ -25,6 +25,7 @@
<div class="row">
<div class="col-lg-6 offset-lg-3 text-center">
<div class="form-floating mb-3">
+ <input type="hidden" value="{{.extZkey}}" name="zkey">
<input id="labelInput" name="label" class="form-control text-center" placeholder="" maxlength="63" type="text" aria-describedby="reg-suffix" required autofocus>
<label for="labelInput">Your name. e.g. alice</label>
</div>
diff --git a/web/templates/name.html b/web/templates/name.html
@@ -34,7 +34,7 @@
<div class="col-md-12 alert alert-light">
<h4>Zone information</h4>
<div class="form-floating mb-3">
- <input name="zkey" id="zkeyInput" class="form-control" maxlength="63" type="text" placeholder="Enter your zone key here!" required autofocus>
+ <input name="zkey" value="{{.zkey}}" id="zkeyInput" class="form-control" maxlength="63" type="text" placeholder="Enter your zone key here!" required autofocus>
<label for="zkeyInput">Enter your zone key here</label>
</div>
<input class="btn btn-primary" type="submit" value="Register for a duration of {{.registrationDaysCount}} days for {{.cost}}">