diff --git a/common/forum_perms.go b/common/forum_perms.go index 2fd452ef..60672235 100644 --- a/common/forum_perms.go +++ b/common/forum_perms.go @@ -155,9 +155,15 @@ func PermmapToQuery(permmap map[string]*ForumPerms, fid int) error { return err } - // 6 is the ID of the Not Loggedin Group - // TODO: Use a shared variable rather than a literal for the group ID - err = ReplaceForumPermsForGroupTx(tx, 6, map[int]string{fid: ""}, map[int]*ForumPerms{fid: permmap["guests"]}) + // TODO: The group ID is probably a variable somewhere. Find it and use it. + // Group 5 is the Awaiting Activation group + err = ReplaceForumPermsForGroupTx(tx, 5, map[int]string{fid: ""}, map[int]*ForumPerms{fid: permmap["guests"]}) + if err != nil { + return err + } + + // TODO: Consult a config setting instead of GuestUser? + err = ReplaceForumPermsForGroupTx(tx, GuestUser.Group, map[int]string{fid: ""}, map[int]*ForumPerms{fid: permmap["guests"]}) if err != nil { return err } diff --git a/gen_router.go b/gen_router.go index 8132033d..c5be1519 100644 --- a/gen_router.go +++ b/gen_router.go @@ -745,7 +745,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } common.RouteViewCounter.Bump(53) - err = routeBanSubmit(w,req,user) + err = routeBanSubmit(w,req,user,extraData) case "/users/unban/": err = common.NoSessionMismatch(w,req,user) if err != nil { @@ -760,7 +760,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } common.RouteViewCounter.Bump(54) - err = routeUnban(w,req,user) + err = routeUnban(w,req,user,extraData) case "/users/activate/": err = common.NoSessionMismatch(w,req,user) if err != nil { @@ -775,7 +775,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } common.RouteViewCounter.Bump(55) - err = routeActivate(w,req,user) + err = routeActivate(w,req,user,extraData) case "/users/ips/": err = common.MemberOnly(w,req,user) if err != nil { diff --git a/mod_routes.go b/mod_routes.go index 073f854c..cd883a56 100644 --- a/mod_routes.go +++ b/mod_routes.go @@ -603,14 +603,14 @@ func routeIps(w http.ResponseWriter, r *http.Request, user common.User) common.R return nil } -func routeBanSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { +func routeBanSubmit(w http.ResponseWriter, r *http.Request, user common.User, suid string) common.RouteError { if !user.Perms.BanUsers { return common.NoPermissions(w, r, user) } - uid, err := strconv.Atoi(r.URL.Path[len("/users/ban/submit/"):]) + uid, err := strconv.Atoi(suid) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } if uid == -2 { return common.LocalError("Why don't you like Merlin?", w, r, user) @@ -676,14 +676,14 @@ func routeBanSubmit(w http.ResponseWriter, r *http.Request, user common.User) co return nil } -func routeUnban(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { +func routeUnban(w http.ResponseWriter, r *http.Request, user common.User, suid string) common.RouteError { if !user.Perms.BanUsers { return common.NoPermissions(w, r, user) } - uid, err := strconv.Atoi(r.URL.Path[len("/users/unban/"):]) + uid, err := strconv.Atoi(suid) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } targetUser, err := common.Users.Get(uid) @@ -715,14 +715,14 @@ func routeUnban(w http.ResponseWriter, r *http.Request, user common.User) common return nil } -func routeActivate(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { +func routeActivate(w http.ResponseWriter, r *http.Request, user common.User, suid string) common.RouteError { if !user.Perms.ActivateUsers { return common.NoPermissions(w, r, user) } - uid, err := strconv.Atoi(r.URL.Path[len("/users/activate/"):]) + uid, err := strconv.Atoi(suid) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } targetUser, err := common.Users.Get(uid) diff --git a/panel_routes.go b/panel_routes.go index b1107681..895b790f 100644 --- a/panel_routes.go +++ b/panel_routes.go @@ -948,7 +948,7 @@ func routePanelUsersEdit(w http.ResponseWriter, r *http.Request, user common.Use uid, err := strconv.Atoi(suid) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } targetUser, err := common.Users.Get(uid) @@ -1003,7 +1003,7 @@ func routePanelUsersEditSubmit(w http.ResponseWriter, r *http.Request, user comm uid, err := strconv.Atoi(suid) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } targetUser, err := common.Users.Get(uid) diff --git a/router_gen/routes.go b/router_gen/routes.go index 3cac9066..8e3faa65 100644 --- a/router_gen/routes.go +++ b/router_gen/routes.go @@ -47,9 +47,9 @@ func buildUserRoutes() { // TODO: Auto test and manual test these routes userGroup = newRouteGroup("/users/") userGroup.Routes( - Action("routeBanSubmit", "/users/ban/submit/"), - Action("routeUnban", "/users/unban/"), - Action("routeActivate", "/users/activate/"), + Action("routeBanSubmit", "/users/ban/submit/", "extraData"), + Action("routeUnban", "/users/unban/", "extraData"), + Action("routeActivate", "/users/activate/", "extraData"), MemberView("routeIps", "/users/ips/"), // TODO: .Perms("ViewIPs")? ) addRouteGroup(userGroup) diff --git a/routes.go b/routes.go index 24efdc80..87f8bc2f 100644 --- a/routes.go +++ b/routes.go @@ -643,7 +643,7 @@ func routeProfile(w http.ResponseWriter, r *http.Request, user common.User) comm pid, err := strconv.Atoi(halves[1]) if err != nil { - return common.LocalError("The provided common.User ID is not a valid number.", w, r, user) + return common.LocalError("The provided UserID is not a valid number.", w, r, user) } var puser *common.User