[MM-25647]: ability to permanently delete users (#14944)

Summary:
    Config option to allow permanent user deletion ServiceSettings.EnableAPIUserDeletion
    Expose permanent user deletion through API
    Local mode for delete user for use in mmctl

Ticket Link:
    Server part of https://mattermost.atlassian.net/browse/MM-25647
Этот коммит содержится в:
Ashish Bhate
2020-07-22 12:02:23 +00:00
коммит произвёл GitHub
родитель 7e3d76b9a2
Коммит 7602dc0b19
6 изменённых файлов: 117 добавлений и 18 удалений

Просмотреть файл

@@ -1240,6 +1240,16 @@ func (c *Client4) DeleteUser(userId string) (bool, *Response) {
return CheckStatusOK(r), BuildResponse(r)
}
// PermanentDeleteUser deletes a user in the system based on the provided user id string.
func (c *Client4) PermanentDeleteUser(userId string) (bool, *Response) {
r, err := c.DoApiDelete(c.GetUserRoute(userId) + "?permanent=" + c.boolString(true))
if err != nil {
return false, BuildErrorResponse(r, err)
}
defer closeBody(r)
return CheckStatusOK(r), BuildResponse(r)
}
// ConvertUserToBot converts a user to a bot user.
func (c *Client4) ConvertUserToBot(userId string) (*Bot, *Response) {
r, err := c.DoApiPost(c.GetUserRoute(userId)+"/convert_to_bot", "")

Просмотреть файл

@@ -327,6 +327,7 @@ type ServiceSettings struct {
DEPRECATED_DO_NOT_USE_ImageProxyURL *string `json:"ImageProxyURL" mapstructure:"ImageProxyURL"` // This field is deprecated and must not be used.
DEPRECATED_DO_NOT_USE_ImageProxyOptions *string `json:"ImageProxyOptions" mapstructure:"ImageProxyOptions"` // This field is deprecated and must not be used.
EnableAPITeamDeletion *bool
EnableAPIUserDeletion *bool
ExperimentalEnableHardenedMode *bool
DisableLegacyMFA *bool `restricted:"true"`
ExperimentalStrictCSRFEnforcement *bool `restricted:"true"`
@@ -699,6 +700,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
s.EnableAPITeamDeletion = NewBool(false)
}
if s.EnableAPIUserDeletion == nil {
s.EnableAPIUserDeletion = NewBool(false)
}
if s.ExperimentalEnableHardenedMode == nil {
s.ExperimentalEnableHardenedMode = NewBool(false)
}