MM-45715: Fix incorrect permissions (Round 2) (#20731)

We missed a case to return if there are no
items in the slice. Otherwise it falls through
and returns false incorrectly.

Rectified the tests to trigger the case.

https://mattermost.atlassian.net/browse/MM-45715

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-07-29 09:58:44 +05:30
коммит произвёл GitHub
родитель b9d062ddfa
Коммит 887bc0173e
2 изменённых файлов: 31 добавлений и 3 удалений

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

@@ -59,6 +59,10 @@ func (a *App) SessionHasPermissionToTeam(session model.Session, teamID string, p
// SessionHasPermissionToTeams returns true only if user has access to all teams.
func (a *App) SessionHasPermissionToTeams(c request.CTX, session model.Session, teamIDs []string, permission *model.Permission) bool {
if len(teamIDs) == 0 {
return true
}
for _, teamID := range teamIDs {
if teamID == "" {
return false
@@ -126,6 +130,10 @@ func (a *App) SessionHasPermissionToChannel(c request.CTX, session model.Session
// SessionHasPermissionToChannels returns true only if user has access to all channels.
func (a *App) SessionHasPermissionToChannels(c request.CTX, session model.Session, channelIDs []string, permission *model.Permission) bool {
if len(channelIDs) == 0 {
return true
}
for _, channelID := range channelIDs {
if channelID == "" {
return false