actually got AmAutoJoinCommunities to work

This commit is contained in:
2025-10-09 13:30:45 -06:00
parent 8fdc3ded44
commit e04c903b11
3 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -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
+9 -1
View File
@@ -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 {
-2
View File
@@ -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