MM-49813 - validate inviter permissions when sending invitations to private channels (#22119)
* MM-49813 - validate members invitation permissions to private channels * Validate on the receiver side that the sender id still has permissions to invite * add translations * fix texts * simplify implementation * remove local test hardcoded data * add test to user_test * fix vet warning * Add comments to validate user permissions function Co-authored-by: Martin Kraft <martin@upspin.org> * regenerate app layer iface * fix unit test * fix app user_tests --------- Co-authored-by: Martin Kraft <martin@upspin.org>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e055df27e8
Коммит
ae3c21dd79
10
app/user.go
10
app/user.go
@@ -70,7 +70,15 @@ func (a *App) CreateUserWithToken(c request.CTX, user *model.User, token *model.
|
||||
}
|
||||
}
|
||||
|
||||
channels, nErr := a.Srv().Store().Channel().GetChannelsByIds(strings.Split(tokenData["channels"], " "), false)
|
||||
// find the sender id and grab the channels in order to validate
|
||||
// the sender id still belongs to team and to private channels
|
||||
senderId := tokenData["senderId"]
|
||||
channelIds := strings.Split(tokenData["channels"], " ")
|
||||
|
||||
// filter the channels the original inviter has still permissions over
|
||||
channelIds = a.ValidateUserPermissionsOnChannels(c, senderId, channelIds)
|
||||
|
||||
channels, nErr := a.Srv().Store().Channel().GetChannelsByIds(channelIds, false)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("CreateUserWithToken", "app.channel.get_channels_by_ids.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user