straightened out the "account creation" workflow

This commit is contained in:
2025-10-08 16:36:23 -06:00
parent 05dc2aa448
commit 60b0ec8a5d
10 changed files with 54 additions and 38 deletions
+11 -2
View File
@@ -40,6 +40,7 @@ type DialogItem struct {
type Dialog struct {
Name string `yaml:"name"`
FormName string `yaml:"formName"`
Options string `yaml:"options,omitempty"`
MenuSelector string `yaml:"menuSelector,omitempty"`
Title string `yaml:"title"`
Action string `yaml:"action"`
@@ -104,6 +105,11 @@ func (fld *DialogItem) IsChecked() bool {
return false
}
// ValueInt returns the value of the field as an integer.
func (fld *DialogItem) ValueInt() (int, error) {
return strconv.Atoi(fld.Value)
}
// ValueRange returns the minimum and maximum values for an integer field.
func (fld *DialogItem) ValueRange() VRange {
if fld.Type == "integer" && fld.Param != "" {
@@ -169,6 +175,9 @@ func (d *Dialog) Render(ctxt AmContext) (string, any, error) {
ctxt.VarMap().Set("amsterdam_required", required)
ctxt.VarMap().Set("amsterdam_dialog", d)
ctxt.VarMap().Set("amsterdam_pageTitle", d.Title)
if strings.Contains(d.Options, "suppresslogin") {
ctxt.VarMap().Set("amsterdam_suppressLogin", true)
}
return "framed_template", "dialog.jet", nil
}
@@ -417,11 +426,11 @@ var validators = map[string]validatorFunc{
* Standard Go error status.
*/
func (d *Dialog) Validate() error {
for _, fld := range d.Fields {
for i, fld := range d.Fields {
if len(fld.Value) > 0 || fld.Required {
vfunc := validators[fld.Type]
if vfunc != nil {
err := vfunc(&fld)
err := vfunc(&(d.Fields[i]))
if err != nil {
return err
}
+1
View File
@@ -10,6 +10,7 @@ name: "login"
formName: "loginform"
menuSelector: "top"
title: "Log In"
options: "suppresslogin"
action: "/login"
instructions: >
Forgot your password? Enter your user name and click the <b>Reminder</b> button to receive
+1
View File
@@ -10,6 +10,7 @@ name: "newaccount"
formName: "createform"
menuSelector: "top"
title: "Create New Account"
options: "suppresslogin"
action: "/newacct2"
instructions: >
To create a new account, please enter your information below.
+1
View File
@@ -10,6 +10,7 @@ name: "verify"
formName: "verifyform"
menuSelector: "top"
title: "Verify E-mail Address"
options: "suppresslogin"
action: "/verify"
instructions: >
Check your E-mail, then enter the confirmation number that was E-mailed to you in the field below.
+12 -8
View File
@@ -58,16 +58,20 @@
<span class="text-white text-base">
{{ if .CurrentUser().IsAnon }}
You are not logged in
<span class="mx-2">-</span>
<a href="/login" class="text-yellow-300 hover:text-yellow-400">Log In</a>
<span class="mx-2">|</span>
<a href="/newacct" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
{{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }}
<span class="mx-2">-</span>
<a href="/login" class="text-yellow-300 hover:text-yellow-400">Log In</a>
<span class="mx-2">|</span>
<a href="/newacct" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
{{ end }}
{{ else }}
You are logged in as <b>{{ .CurrentUser().Username }}</b>
<span class="mx-2">-</span>
<a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a>
<span class="mx-2">|</span>
<a href="/TODO/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a>
{{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }}
<span class="mx-2">-</span>
<a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a>
<span class="mx-2">|</span>
<a href="/TODO/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a>
{{ end }}
{{ end }}
</span>
</div>