MM-18081 Except bots from team email domain restrictions (#12041)
* Except bots from team email domain restrictions * Fix style
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
adb1a98760
Коммит
50e97bd9d3
@@ -89,6 +89,9 @@ func (a *App) isTeamEmailAddressAllowed(email string, allowedDomains string) boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) isTeamEmailAllowed(user *model.User, team *model.Team) bool {
|
func (a *App) isTeamEmailAllowed(user *model.User, team *model.Team) bool {
|
||||||
|
if user.IsBot {
|
||||||
|
return true
|
||||||
|
}
|
||||||
email := strings.ToLower(user.Email)
|
email := strings.ToLower(user.Email)
|
||||||
return a.isTeamEmailAddressAllowed(email, team.AllowedDomains)
|
return a.isTeamEmailAddressAllowed(email, team.AllowedDomains)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func TestAddUserToTeam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("block user by domain", func(t *testing.T) {
|
t.Run("block user by domain but allow bot", func(t *testing.T) {
|
||||||
th.BasicTeam.AllowedDomains = "example.com"
|
th.BasicTeam.AllowedDomains = "example.com"
|
||||||
if _, err := th.App.UpdateTeam(th.BasicTeam); err != nil {
|
if _, err := th.App.UpdateTeam(th.BasicTeam); err != nil {
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
@@ -131,10 +131,20 @@ func TestAddUserToTeam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer th.App.PermanentDeleteUser(&user)
|
defer th.App.PermanentDeleteUser(&user)
|
||||||
|
|
||||||
if _, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err == nil || err.Where != "JoinUserToTeam" {
|
if _, err = th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err == nil || err.Where != "JoinUserToTeam" {
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
t.Fatal("Should not add authservice user")
|
t.Fatal("Should not add authservice user")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bot, err := th.App.CreateBot(&model.Bot{
|
||||||
|
Username: "somebot",
|
||||||
|
Description: "a bot",
|
||||||
|
OwnerId: th.BasicUser.Id,
|
||||||
|
})
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
_, err = th.App.AddUserToTeam(th.BasicTeam.Id, bot.UserId, "")
|
||||||
|
assert.Nil(t, err, "should be able to add bot to domain restricted team")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("block user with subdomain", func(t *testing.T) {
|
t.Run("block user with subdomain", func(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user