[MM-25646] Adds the permanent delete all users endpoint to the local API (#14903)
* [MM-25646] Adds the permanent delete all users endpoint to the local API * Add a check to ensure that teams and channels are not deleted * Fix linter * Fix audit record name for consistency with method name Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
48ed86ddc7
Коммит
eff2209a7e
@@ -6,11 +6,13 @@ package api4
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/audit"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
func (api *API) InitUserLocal() {
|
||||
api.BaseRoutes.Users.Handle("", api.ApiLocal(getUsers)).Methods("GET")
|
||||
api.BaseRoutes.Users.Handle("", api.ApiLocal(localPermanentDeleteAllUsers)).Methods("DELETE")
|
||||
api.BaseRoutes.Users.Handle("", api.ApiLocal(createUser)).Methods("POST")
|
||||
api.BaseRoutes.Users.Handle("/password/reset/send", api.ApiLocal(sendPasswordReset)).Methods("POST")
|
||||
api.BaseRoutes.Users.Handle("/ids", api.ApiLocal(getUsersByIds)).Methods("POST")
|
||||
@@ -29,6 +31,19 @@ func (api *API) InitUserLocal() {
|
||||
api.BaseRoutes.User.Handle("/tokens", api.ApiLocal(createUserAccessToken)).Methods("POST")
|
||||
}
|
||||
|
||||
func localPermanentDeleteAllUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec := c.MakeAuditRecord("localPermanentDeleteAllUsers", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
if err := c.App.PermanentDeleteAllUsers(); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
auditRec.Success()
|
||||
ReturnStatusOK(w)
|
||||
}
|
||||
|
||||
func localGetUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.RequireUsername()
|
||||
if c.Err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user