welcome: successful registration page (#82)
diff --git a/core/installer/welcome/create-account-success.html b/core/installer/welcome/create-account-success.html
new file mode 100644
index 0000000..7432da3
--- /dev/null
+++ b/core/installer/welcome/create-account-success.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en" data-theme="light">
+ <head>
+ <link rel="stylesheet" href="/static/pico.2.0.6.min.css">
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1" >
+ <title>Successful Registration</title>
+ </head>
+ <body>
+ <main class="container">
+ <div>
+ <p>Your account has been successfully created.</p>
+ <p>Click <a href="{{ .LoginAddr }}">here</a> to authenticate.</p>
+ </div>
+ </main>
+ </body>
+</html>
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)
}