diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-05-28 10:35:27 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-05-28 10:35:27 -0400 |
commit | c180cdbd1cba584c6e74cae7042de2290b51feb6 (patch) | |
tree | 19002d12a212d0bcc0e09d31410df548b93d77ef /api4/user.go | |
parent | 7225abddeefb569f1f2da739211d7797b63814a2 (diff) | |
parent | c37d153ffb276e501660133de836a61eec25e544 (diff) | |
download | chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.tar.gz chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.tar.bz2 chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'api4/user.go')
-rw-r--r-- | api4/user.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/api4/user.go b/api4/user.go index 2a539a551..ea90d2127 100644 --- a/api4/user.go +++ b/api4/user.go @@ -713,6 +713,12 @@ func updateUserActive(c *Context, w http.ResponseWriter, r *http.Request) { return } + // if EnableUserDeactivation flag is disabled the user cannot deactivate himself. + if isSelfDeactive && !*c.App.GetConfig().TeamSettings.EnableUserDeactivation { + c.Err = model.NewAppError("updateUserActive", "api.user.update_active.not_enable.app_error", nil, "userId="+c.Params.UserId, http.StatusUnauthorized) + return + } + var user *model.User var err *model.AppError @@ -725,6 +731,13 @@ func updateUserActive(c *Context, w http.ResponseWriter, r *http.Request) { c.Err = err } else { c.LogAuditWithUserId(user.Id, fmt.Sprintf("active=%v", active)) + if isSelfDeactive { + c.App.Go(func() { + if err = c.App.SendDeactivateAccountEmail(user.Email, user.Locale, c.App.GetSiteURL()); err != nil { + mlog.Error(err.Error()) + } + }) + } ReturnStatusOK(w) } } |