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
}
// 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
}

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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