mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-56513 Prevent deactivated users to be added as channel members (#25954)
* Prevent deactivated users to be added as channel members * remove "deactivated" from error message
This commit is contained in:
parent
5c63bb7e0f
commit
9ff26f7b4f
@ -1695,6 +1695,10 @@ func (a *App) AddChannelMember(c request.CTX, userID string, channel *model.Chan
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if user.DeleteAt > 0 {
|
||||
return nil, model.NewAppError("AddChannelMember", "app.channel.add_member.deleted_user.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
var userRequestor *model.User
|
||||
if opts.UserRequestorID != "" {
|
||||
if userRequestor, err = a.GetUser(opts.UserRequestorID); err != nil {
|
||||
|
@ -764,6 +764,22 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddChannelMemberDeletedUser(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
user := th.CreateUser()
|
||||
_, err := th.App.AddTeamMember(th.Context, th.BasicTeam.Id, user.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
deactivated, err := th.App.UpdateActive(th.Context, user, false)
|
||||
require.Greater(t, deactivated.DeleteAt, int64(0))
|
||||
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.AddChannelMember(th.Context, user.Id, th.BasicChannel, ChannelMemberOpts{})
|
||||
require.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestAppUpdateChannelScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
@ -4854,6 +4854,10 @@
|
||||
"id": "app.bot.permenent_delete.bad_id",
|
||||
"translation": "Unable to delete the bot."
|
||||
},
|
||||
{
|
||||
"id": "app.channel.add_member.deleted_user.app_error",
|
||||
"translation": "Unable to add thr user as a member of the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.channel.analytics_type_count.app_error",
|
||||
"translation": "Unable to get channel type counts."
|
||||
|
Loading…
Reference in New Issue
Block a user