actually got AmAutoJoinCommunities to work
This commit is contained in:
@@ -159,7 +159,7 @@ func AmAutoJoinCommunities(user *User) error {
|
|||||||
var lock bool
|
var lock bool
|
||||||
rows.Scan(&cid, &lock)
|
rows.Scan(&cid, &lock)
|
||||||
if !slices.Contains(current, cid) {
|
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)
|
cid, user.Uid, grantLevel, lock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
|||||||
+9
-1
@@ -472,8 +472,13 @@ func AmCreateNewUser(username string, password string, reminder string, dob *tim
|
|||||||
AmStoreAudit(ar)
|
AmStoreAudit(ar)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
unlock := true
|
||||||
amdb.Exec("LOCK TABLES users WRITE, userprefs WRITE, propuser WRITE, commmember WRITE, sideboxes WRITE, confhotlist WRITE;")
|
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.
|
// Test if the user name is already taken.
|
||||||
rs, err := amdb.Query("SELECT uid FROM users WHERE username = ?", username)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
amdb.Exec("UNLOCK TABLES;")
|
||||||
|
unlock = false
|
||||||
|
|
||||||
// auto-join communities
|
// auto-join communities
|
||||||
err = AmAutoJoinCommunities(user)
|
err = AmAutoJoinCommunities(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -296,8 +296,6 @@ func NewAmContext(ctxt echo.Context) (AmContext, error) {
|
|||||||
sess.Options = defoptions
|
sess.Options = defoptions
|
||||||
if sess.IsNew {
|
if sess.IsNew {
|
||||||
setupAmSession(sess)
|
setupAmSession(sess)
|
||||||
} else {
|
|
||||||
log.Debugf("took the not-new-session path")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &rc, err
|
return &rc, err
|
||||||
|
|||||||
Reference in New Issue
Block a user