welcome: successful registration page (#82)
diff --git a/core/installer/welcome/welcome.go b/core/installer/welcome/welcome.go
index 4d30784..5184a8e 100644
--- a/core/installer/welcome/welcome.go
+++ b/core/installer/welcome/welcome.go
@@ -19,6 +19,9 @@
//go:embed create-account.html
var indexHtml []byte
+//go:embed create-account-success.html
+var successHtml []byte
+
//go:embed static/*
var staticAssets embed.FS
@@ -27,6 +30,7 @@
repo installer.RepoIO
nsCreator installer.NamespaceCreator
createAccountAddr string
+ loginAddr string
}
func NewServer(
@@ -34,12 +38,14 @@
repo installer.RepoIO,
nsCreator installer.NamespaceCreator,
createAccountAddr string,
+ loginAddr string,
) *Server {
return &Server{
port,
repo,
nsCreator,
createAccountAddr,
+ loginAddr,
}
}
@@ -127,6 +133,23 @@
}
}
+func renderRegistrationSuccess(w http.ResponseWriter, loginAddr string) {
+ data := struct {
+ LoginAddr string
+ }{
+ LoginAddr: loginAddr,
+ }
+ tmpl, err := template.New("create-account-success").Parse(string(successHtml))
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ if err := tmpl.Execute(w, data); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
func (s *Server) createAdminAccount(w http.ResponseWriter, r *http.Request) {
req, err := extractReq(r)
if err != nil {
@@ -209,8 +232,5 @@
}
}
}
- if _, err := w.Write([]byte("OK")); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
+ renderRegistrationSuccess(w, s.loginAddr)
}