Fixed a few mangled error strings.

Fixed the routeBanSubmit, routeUnban, and routeActivate routes.
Members who are awaiting activation are now treated like guests by the preset system.
This commit is contained in:
Azareal 2017-12-25 02:41:10 +00:00
parent 964d219407
commit e492088b97
6 changed files with 27 additions and 21 deletions

View File

@ -155,9 +155,15 @@ func PermmapToQuery(permmap map[string]*ForumPerms, fid int) error {
return err return err
} }
// 6 is the ID of the Not Loggedin Group // TODO: The group ID is probably a variable somewhere. Find it and use it.
// TODO: Use a shared variable rather than a literal for the group ID // Group 5 is the Awaiting Activation group
err = ReplaceForumPermsForGroupTx(tx, 6, map[int]string{fid: ""}, map[int]*ForumPerms{fid: permmap["guests"]}) 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 { if err != nil {
return err return err
} }

View File

@ -745,7 +745,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
common.RouteViewCounter.Bump(53) common.RouteViewCounter.Bump(53)
err = routeBanSubmit(w,req,user) err = routeBanSubmit(w,req,user,extraData)
case "/users/unban/": case "/users/unban/":
err = common.NoSessionMismatch(w,req,user) err = common.NoSessionMismatch(w,req,user)
if err != nil { if err != nil {
@ -760,7 +760,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
common.RouteViewCounter.Bump(54) common.RouteViewCounter.Bump(54)
err = routeUnban(w,req,user) err = routeUnban(w,req,user,extraData)
case "/users/activate/": case "/users/activate/":
err = common.NoSessionMismatch(w,req,user) err = common.NoSessionMismatch(w,req,user)
if err != nil { if err != nil {
@ -775,7 +775,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
common.RouteViewCounter.Bump(55) common.RouteViewCounter.Bump(55)
err = routeActivate(w,req,user) err = routeActivate(w,req,user,extraData)
case "/users/ips/": case "/users/ips/":
err = common.MemberOnly(w,req,user) err = common.MemberOnly(w,req,user)
if err != nil { if err != nil {

View File

@ -603,14 +603,14 @@ func routeIps(w http.ResponseWriter, r *http.Request, user common.User) common.R
return nil 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 { if !user.Perms.BanUsers {
return common.NoPermissions(w, r, user) 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 { 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 { if uid == -2 {
return common.LocalError("Why don't you like Merlin?", w, r, user) 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 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 { if !user.Perms.BanUsers {
return common.NoPermissions(w, r, user) return common.NoPermissions(w, r, user)
} }
uid, err := strconv.Atoi(r.URL.Path[len("/users/unban/"):]) uid, err := strconv.Atoi(suid)
if err != nil { 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) targetUser, err := common.Users.Get(uid)
@ -715,14 +715,14 @@ func routeUnban(w http.ResponseWriter, r *http.Request, user common.User) common
return nil 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 { if !user.Perms.ActivateUsers {
return common.NoPermissions(w, r, user) return common.NoPermissions(w, r, user)
} }
uid, err := strconv.Atoi(r.URL.Path[len("/users/activate/"):]) uid, err := strconv.Atoi(suid)
if err != nil { 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) targetUser, err := common.Users.Get(uid)

View File

@ -948,7 +948,7 @@ func routePanelUsersEdit(w http.ResponseWriter, r *http.Request, user common.Use
uid, err := strconv.Atoi(suid) uid, err := strconv.Atoi(suid)
if err != nil { 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) 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) uid, err := strconv.Atoi(suid)
if err != nil { 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) targetUser, err := common.Users.Get(uid)

View File

@ -47,9 +47,9 @@ func buildUserRoutes() {
// TODO: Auto test and manual test these routes // TODO: Auto test and manual test these routes
userGroup = newRouteGroup("/users/") userGroup = newRouteGroup("/users/")
userGroup.Routes( userGroup.Routes(
Action("routeBanSubmit", "/users/ban/submit/"), Action("routeBanSubmit", "/users/ban/submit/", "extraData"),
Action("routeUnban", "/users/unban/"), Action("routeUnban", "/users/unban/", "extraData"),
Action("routeActivate", "/users/activate/"), Action("routeActivate", "/users/activate/", "extraData"),
MemberView("routeIps", "/users/ips/"), // TODO: .Perms("ViewIPs")? MemberView("routeIps", "/users/ips/"), // TODO: .Perms("ViewIPs")?
) )
addRouteGroup(userGroup) addRouteGroup(userGroup)

View File

@ -643,7 +643,7 @@ func routeProfile(w http.ResponseWriter, r *http.Request, user common.User) comm
pid, err := strconv.Atoi(halves[1]) pid, err := strconv.Atoi(halves[1])
if err != nil { 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 var puser *common.User