Log out user after setting status to 'banned'

This commit is contained in:
Asaf Gartner 2021-12-21 06:07:55 +02:00
parent 83ef51374d
commit 12eb172f98
1 changed files with 6 additions and 0 deletions

View File

@ -481,6 +481,12 @@ func UserProfileAdminSetStatus(c *RequestContext) ResponseData {
if err != nil { if err != nil {
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to update user status")) return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to update user status"))
} }
if desiredStatus == models.UserStatusBanned {
err = auth.DeleteSessionForUser(c.Context(), c.Conn, c.Req.Form.Get("username"))
if err != nil {
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to log out user"))
}
}
res := c.Redirect(hmnurl.BuildUserProfile(c.Req.Form.Get("username")), http.StatusSeeOther) res := c.Redirect(hmnurl.BuildUserProfile(c.Req.Form.Get("username")), http.StatusSeeOther)
res.AddFutureNotice("success", "Successfully set status") res.AddFutureNotice("success", "Successfully set status")
return res return res