welcome: successful registration page (#82)
diff --git a/core/installer/cmd/welcome.go b/core/installer/cmd/welcome.go
index 41d27f7..b1f3259 100644
--- a/core/installer/cmd/welcome.go
+++ b/core/installer/cmd/welcome.go
@@ -1,14 +1,13 @@
package main
import (
- "golang.org/x/crypto/ssh"
"os"
- "github.com/spf13/cobra"
-
"github.com/giolekva/pcloud/core/installer"
"github.com/giolekva/pcloud/core/installer/soft"
"github.com/giolekva/pcloud/core/installer/welcome"
+ "github.com/spf13/cobra"
+ "golang.org/x/crypto/ssh"
)
var welcomeFlags struct {
@@ -16,6 +15,7 @@
sshKey string
port int
createAccountAddr string
+ loginAddr string
}
func welcomeCmd() *cobra.Command {
@@ -47,6 +47,12 @@
"",
"",
)
+ cmd.Flags().StringVar(
+ &welcomeFlags.loginAddr,
+ "login-addr",
+ "",
+ "",
+ )
return cmd
}
@@ -76,6 +82,7 @@
installer.NewRepoIO(repo, signer),
nsCreator,
welcomeFlags.createAccountAddr,
+ welcomeFlags.loginAddr,
)
s.Start()
return nil
diff --git a/core/installer/values-tmpl/welcome.cue b/core/installer/values-tmpl/welcome.cue
index 255cc20..0a11ac9 100644
--- a/core/installer/values-tmpl/welcome.cue
+++ b/core/installer/values-tmpl/welcome.cue
@@ -6,6 +6,7 @@
repoAddr: string
sshPrivateKey: string
createAccountAddr: string
+ loginAddr: string
}
name: "welcome"
@@ -38,6 +39,7 @@
repoAddr: input.repoAddr
sshPrivateKey: base64.Encode(null, input.sshPrivateKey)
createAccountAddr: "http://api.\(global.namespacePrefix)core-auth.svc.cluster.local/identities"
+ loginAddr: "http://accounts-ui.\(global.domain)"
ingress: {
className: _ingressPublic
domain: "welcome.\(global.domain)"
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)
}