diff --git a/database/community.go b/database/community.go index da157e6..6589bf7 100644 --- a/database/community.go +++ b/database/community.go @@ -159,7 +159,7 @@ func AmAutoJoinCommunities(user *User) error { var lock bool rows.Scan(&cid, &lock) if !slices.Contains(current, cid) { - _, err = amdb.Exec("INSERT INTO commmember (commid, uid, granted_lvl, locked) VALUES (?. ?, ?, ?)", + _, err = amdb.Exec("INSERT INTO commmember (commid, uid, granted_lvl, locked) VALUES (?, ?, ?, ?)", cid, user.Uid, grantLevel, lock) if err != nil { break diff --git a/database/user.go b/database/user.go index 32a3a7b..068931e 100644 --- a/database/user.go +++ b/database/user.go @@ -472,8 +472,13 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim AmStoreAudit(ar) }() + unlock := true amdb.Exec("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, commmember WRITE, sideboxes WRITE, confhotlist WRITE;") - defer amdb.Exec("UNLOCK TABLES;") + defer func() { + if unlock { + amdb.Exec("UNLOCK TABLES;") + } + }() // Test if the user name is already taken. rs, err := amdb.Query("SELECT uid FROM users WHERE username = ?", username) @@ -525,6 +530,9 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim return nil, err } + amdb.Exec("UNLOCK TABLES;") + unlock = false + // auto-join communities err = AmAutoJoinCommunities(user) if err != nil { diff --git a/ui/amcontext.go b/ui/amcontext.go index 3e6da78..569b01a 100644 --- a/ui/amcontext.go +++ b/ui/amcontext.go @@ -296,8 +296,6 @@ func NewAmContext(ctxt echo.Context) (AmContext, error) { sess.Options = defoptions if sess.IsNew { setupAmSession(sess) - } else { - log.Debugf("took the not-new-session path") } } return &rc, err