straightened out the "account creation" workflow
This commit is contained in:
@@ -130,7 +130,7 @@ func (ci *ContactInfo) Save() (bool, error) {
|
|||||||
addr2, locality, region, pcode, country, phone, fax, mobile, email, pvt_addr, pvt_phone, pvt_fax,
|
addr2, locality, region, pcode, country, phone, fax, mobile, email, pvt_addr, pvt_phone, pvt_fax,
|
||||||
pvt_email, owner_uid, owner_commid, photo_url, url, lastupdate)
|
pvt_email, owner_uid, owner_commid, photo_url, url, lastupdate)
|
||||||
VALUES (:given_name, :family_name, :middle_init, :prefix, :suffix, :company, :addr1, :addr2, :locality,
|
VALUES (:given_name, :family_name, :middle_init, :prefix, :suffix, :company, :addr1, :addr2, :locality,
|
||||||
:region:, :pcode, :country, :phone, :fax, :mobile, :email, :pvt_addr, :pvt_phone, :pvt_fax, :pvt_email,
|
:region, :pcode, :country, :phone, :fax, :mobile, :email, :pvt_addr, :pvt_phone, :pvt_fax, :pvt_email,
|
||||||
:owner_uid, :owner_commid, :photo_url, :url, NOW())`, ci)
|
:owner_uid, :owner_commid, :photo_url, :url, NOW())`, ci)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|||||||
+4
-20
@@ -19,7 +19,7 @@ type Sidebox struct {
|
|||||||
// copySideboxes copies sideboxes from one user to another.
|
// copySideboxes copies sideboxes from one user to another.
|
||||||
func copySideboxes(toUid int32, fromUid int32) error {
|
func copySideboxes(toUid int32, fromUid int32) error {
|
||||||
sbox := make([]Sidebox, 0, 3)
|
sbox := make([]Sidebox, 0, 3)
|
||||||
err := amdb.Select(sbox, "SELECT * from sideboxes WHERE uid = ?", fromUid)
|
err := amdb.Select(&sbox, "SELECT * from sideboxes WHERE uid = ?", fromUid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, sb := range sbox {
|
for _, sb := range sbox {
|
||||||
_, err := amdb.Exec("INSERT INTO sideboxes (uid, boxid, sequence, param) VALUES (?, ?, ?, ?)", toUid, sb.Boxid, sb.Sequence, sb.Param)
|
_, err := amdb.Exec("INSERT INTO sideboxes (uid, boxid, sequence, param) VALUES (?, ?, ?, ?)", toUid, sb.Boxid, sb.Sequence, sb.Param)
|
||||||
@@ -39,23 +39,7 @@ func copySideboxes(toUid int32, fromUid int32) error {
|
|||||||
* Standard Go error status
|
* Standard Go error status
|
||||||
*/
|
*/
|
||||||
func AmGetSideboxes(uid int32) ([]*Sidebox, error) {
|
func AmGetSideboxes(uid int32) ([]*Sidebox, error) {
|
||||||
stmt, err := amdb.Preparex("SELECT * FROM sideboxes WHERE uid = ? ORDER BY SEQUENCE")
|
sboxes := make([]*Sidebox, 0, 3)
|
||||||
if err == nil {
|
err := amdb.Select(&sboxes, "SELECT * FROM sideboxes WHERE uid = ? ORDER BY SEQUENCE", uid)
|
||||||
defer stmt.Close()
|
return sboxes, err
|
||||||
rows, err := stmt.Queryx(uid)
|
|
||||||
if err == nil {
|
|
||||||
defer rows.Close()
|
|
||||||
sboxes := make([]*Sidebox, 0, 3)
|
|
||||||
for i := 0; rows.Next(); i++ {
|
|
||||||
box := Sidebox{}
|
|
||||||
rows.StructScan(&box)
|
|
||||||
sboxes = append(sboxes, &box)
|
|
||||||
}
|
|
||||||
if rows.Err() == nil {
|
|
||||||
return sboxes, nil
|
|
||||||
}
|
|
||||||
return nil, rows.Err()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-2
@@ -120,6 +120,17 @@ func (u *User) ContactInfo() (*ContactInfo, error) {
|
|||||||
return AmGetContactInfo(u.ContactID)
|
return AmGetContactInfo(u.ContactID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetContactID sets the contact ID of a user.
|
||||||
|
func (u *User) SetContactID(cid int32) error {
|
||||||
|
u.Mutex.Lock()
|
||||||
|
defer u.Mutex.Unlock()
|
||||||
|
if _, err := amdb.Exec("UPDATE users SET contactid = ? WHERE uid = ?", cid, u.Uid); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
u.ContactID = cid
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
/* NewAuthToken generates and returns a new authentication token for the user.
|
/* NewAuthToken generates and returns a new authentication token for the user.
|
||||||
* Returns:
|
* Returns:
|
||||||
* Authentication token value
|
* Authentication token value
|
||||||
@@ -495,12 +506,12 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim
|
|||||||
// add user properties
|
// add user properties
|
||||||
props := make([]UserProperties, 0)
|
props := make([]UserProperties, 0)
|
||||||
anon, _ := getAnonUserID()
|
anon, _ := getAnonUserID()
|
||||||
err = amdb.Select(props, "SELECT * FROM propuser WHERE uid = ?", anon)
|
err = amdb.Select(&props, "SELECT * FROM propuser WHERE uid = ?", anon)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, p := range props {
|
for _, p := range props {
|
||||||
_, err := amdb.Exec("INSTERT INTO propuser (uid, ndx, data) VALUES (?, ?, ?)", user.Uid, p.Index, p.Data)
|
_, err := amdb.Exec("INSERT INTO propuser (uid, ndx, data) VALUES (?, ?, ?)", user.Uid, p.Index, p.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ E-mail Address" dialog on the system when indicated.
|
|||||||
|
|
||||||
Your confirmation number for your account "{{ username }}" is {{ confnum }}.
|
Your confirmation number for your account "{{ username }}" is {{ confnum }}.
|
||||||
|
|
||||||
Access the E-mail verification dialog at <http://example.com/verifyemail>.
|
Access the E-mail verification dialog at <{{ GlobalConfig.Site.BaseURL }}/verify>.
|
||||||
|
|
||||||
Thank you, and enjoy the Amsterdam conferencing system!
|
Thank you, and enjoy the Amsterdam conferencing system!
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ func VerifyEmailForm(ctxt ui.AmContext) (string, any, error) {
|
|||||||
|
|
||||||
// If user is not logged in, this is an error.
|
// If user is not logged in, this is an error.
|
||||||
user := ctxt.CurrentUser()
|
user := ctxt.CurrentUser()
|
||||||
if !user.IsAnon {
|
if user.IsAnon {
|
||||||
return ui.ErrorPage(ctxt, errors.New("you must log in before you can verify your account's E-mail address"))
|
return ui.ErrorPage(ctxt, errors.New("you must log in before you can verify your account's E-mail address"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ func sendEmailConfirmationEmail(user *database.User, ci *database.ContactInfo, r
|
|||||||
if ci != nil && ci.Email != nil && *ci.Email != "" {
|
if ci != nil && ci.Email != nil && *ci.Email != "" {
|
||||||
msg := email.AmNewEmailMessage(user.Uid, remoteIP)
|
msg := email.AmNewEmailMessage(user.Uid, remoteIP)
|
||||||
msg.AddTo(*ci.Email, "")
|
msg.AddTo(*ci.Email, "")
|
||||||
msg.SetTemplate("verify_email.jet")
|
msg.SetTemplate("email_confirm.jet")
|
||||||
msg.AddVariable("username", user.Username)
|
msg.AddVariable("username", user.Username)
|
||||||
msg.AddVariable("confnum", user.EmailConfNum)
|
msg.AddVariable("confnum", user.EmailConfNum)
|
||||||
msg.Send()
|
msg.Send()
|
||||||
@@ -217,7 +217,7 @@ func sendEmailConfirmationEmail(user *database.User, ci *database.ContactInfo, r
|
|||||||
func VerifyEMail(ctxt ui.AmContext) (string, any, error) {
|
func VerifyEMail(ctxt ui.AmContext) (string, any, error) {
|
||||||
// If user is not logged in, this is an error.
|
// If user is not logged in, this is an error.
|
||||||
user := ctxt.CurrentUser()
|
user := ctxt.CurrentUser()
|
||||||
if !user.IsAnon {
|
if user.IsAnon {
|
||||||
return ui.ErrorPage(ctxt, errors.New("you must log in before you can verify your account's E-mail address"))
|
return ui.ErrorPage(ctxt, errors.New("you must log in before you can verify your account's E-mail address"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,8 @@ func VerifyEMail(ctxt ui.AmContext) (string, any, error) {
|
|||||||
if action == "ok" {
|
if action == "ok" {
|
||||||
err = dlg.Validate()
|
err = dlg.Validate()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = user.ConfirmEMailAddress(dlg.Field("num").AuxData.(int32), ctxt.RemoteIP())
|
cn, _ := dlg.Field("num").ValueInt()
|
||||||
|
err = user.ConfirmEMailAddress(int32(cn), ctxt.RemoteIP())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return "redirect", target, nil
|
return "redirect", target, nil
|
||||||
}
|
}
|
||||||
@@ -290,6 +291,7 @@ func NewAccountUserAgreement(ctxt ui.AmContext) (string, any, error) {
|
|||||||
|
|
||||||
ctxt.VarMap().Set("target", target)
|
ctxt.VarMap().Set("target", target)
|
||||||
ctxt.VarMap().Set("amsterdam_pageTitle", "New Account User Agreement")
|
ctxt.VarMap().Set("amsterdam_pageTitle", "New Account User Agreement")
|
||||||
|
ctxt.VarMap().Set("amsterdam_suppressLogin", true)
|
||||||
return "framed_template", "agreement.jet", nil
|
return "framed_template", "agreement.jet", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +384,9 @@ func NewAccount(ctxt ui.AmContext) (string, any, error) {
|
|||||||
ci.Country = dlg.Field("country").ValPtr()
|
ci.Country = dlg.Field("country").ValPtr()
|
||||||
ci.Email = dlg.Field("email").ValPtr()
|
ci.Email = dlg.Field("email").ValPtr()
|
||||||
_, err = ci.Save()
|
_, err = ci.Save()
|
||||||
|
if err == nil {
|
||||||
|
err = user.SetContactID(ci.ContactId)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = sendEmailConfirmationEmail(user, ci, ctxt.RemoteIP())
|
err = sendEmailConfirmationEmail(user, ci, ctxt.RemoteIP())
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -40,6 +40,7 @@ type DialogItem struct {
|
|||||||
type Dialog struct {
|
type Dialog struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
FormName string `yaml:"formName"`
|
FormName string `yaml:"formName"`
|
||||||
|
Options string `yaml:"options,omitempty"`
|
||||||
MenuSelector string `yaml:"menuSelector,omitempty"`
|
MenuSelector string `yaml:"menuSelector,omitempty"`
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
Action string `yaml:"action"`
|
Action string `yaml:"action"`
|
||||||
@@ -104,6 +105,11 @@ func (fld *DialogItem) IsChecked() bool {
|
|||||||
return false
|
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.
|
// ValueRange returns the minimum and maximum values for an integer field.
|
||||||
func (fld *DialogItem) ValueRange() VRange {
|
func (fld *DialogItem) ValueRange() VRange {
|
||||||
if fld.Type == "integer" && fld.Param != "" {
|
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_required", required)
|
||||||
ctxt.VarMap().Set("amsterdam_dialog", d)
|
ctxt.VarMap().Set("amsterdam_dialog", d)
|
||||||
ctxt.VarMap().Set("amsterdam_pageTitle", d.Title)
|
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
|
return "framed_template", "dialog.jet", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,11 +426,11 @@ var validators = map[string]validatorFunc{
|
|||||||
* Standard Go error status.
|
* Standard Go error status.
|
||||||
*/
|
*/
|
||||||
func (d *Dialog) Validate() error {
|
func (d *Dialog) Validate() error {
|
||||||
for _, fld := range d.Fields {
|
for i, fld := range d.Fields {
|
||||||
if len(fld.Value) > 0 || fld.Required {
|
if len(fld.Value) > 0 || fld.Required {
|
||||||
vfunc := validators[fld.Type]
|
vfunc := validators[fld.Type]
|
||||||
if vfunc != nil {
|
if vfunc != nil {
|
||||||
err := vfunc(&fld)
|
err := vfunc(&(d.Fields[i]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ name: "login"
|
|||||||
formName: "loginform"
|
formName: "loginform"
|
||||||
menuSelector: "top"
|
menuSelector: "top"
|
||||||
title: "Log In"
|
title: "Log In"
|
||||||
|
options: "suppresslogin"
|
||||||
action: "/login"
|
action: "/login"
|
||||||
instructions: >
|
instructions: >
|
||||||
Forgot your password? Enter your user name and click the <b>Reminder</b> button to receive
|
Forgot your password? Enter your user name and click the <b>Reminder</b> button to receive
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ name: "newaccount"
|
|||||||
formName: "createform"
|
formName: "createform"
|
||||||
menuSelector: "top"
|
menuSelector: "top"
|
||||||
title: "Create New Account"
|
title: "Create New Account"
|
||||||
|
options: "suppresslogin"
|
||||||
action: "/newacct2"
|
action: "/newacct2"
|
||||||
instructions: >
|
instructions: >
|
||||||
To create a new account, please enter your information below.
|
To create a new account, please enter your information below.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ name: "verify"
|
|||||||
formName: "verifyform"
|
formName: "verifyform"
|
||||||
menuSelector: "top"
|
menuSelector: "top"
|
||||||
title: "Verify E-mail Address"
|
title: "Verify E-mail Address"
|
||||||
|
options: "suppresslogin"
|
||||||
action: "/verify"
|
action: "/verify"
|
||||||
instructions: >
|
instructions: >
|
||||||
Check your E-mail, then enter the confirmation number that was E-mailed to you in the field below.
|
Check your E-mail, then enter the confirmation number that was E-mailed to you in the field below.
|
||||||
|
|||||||
+12
-8
@@ -58,16 +58,20 @@
|
|||||||
<span class="text-white text-base">
|
<span class="text-white text-base">
|
||||||
{{ if .CurrentUser().IsAnon }}
|
{{ if .CurrentUser().IsAnon }}
|
||||||
You are not logged in
|
You are not logged in
|
||||||
<span class="mx-2">-</span>
|
{{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }}
|
||||||
<a href="/login" class="text-yellow-300 hover:text-yellow-400">Log In</a>
|
<span class="mx-2">-</span>
|
||||||
<span class="mx-2">|</span>
|
<a href="/login" class="text-yellow-300 hover:text-yellow-400">Log In</a>
|
||||||
<a href="/newacct" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
|
<span class="mx-2">|</span>
|
||||||
|
<a href="/newacct" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
|
||||||
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
You are logged in as <b>{{ .CurrentUser().Username }}</b>
|
You are logged in as <b>{{ .CurrentUser().Username }}</b>
|
||||||
<span class="mx-2">-</span>
|
{{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }}
|
||||||
<a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a>
|
<span class="mx-2">-</span>
|
||||||
<span class="mx-2">|</span>
|
<a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a>
|
||||||
<a href="/TODO/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a>
|
<span class="mx-2">|</span>
|
||||||
|
<a href="/TODO/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user