mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-13891] Enable team domain restriction for AuthService users (#10209)
* Enable team domain restriction for AuthService users * govet
This commit is contained in:
committed by
Carlos Tadeu Panato Junior
parent
46b05499cc
commit
145fa9a57b
@@ -89,11 +89,6 @@ func (a *App) isTeamEmailAddressAllowed(email string, allowedDomains string) boo
|
||||
|
||||
func (a *App) isTeamEmailAllowed(user *model.User, team *model.Team) bool {
|
||||
email := strings.ToLower(user.Email)
|
||||
|
||||
if len(user.AuthService) > 0 && len(*user.AuthData) > 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
return a.isTeamEmailAddressAllowed(email, team.AllowedDomains)
|
||||
}
|
||||
|
||||
|
||||
@@ -113,12 +113,27 @@ func TestAddUserToTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
user := model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""}
|
||||
ruser, _ := th.App.CreateUser(&user)
|
||||
ruser, err := th.App.CreateUser(&user)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating user: %s", err)
|
||||
}
|
||||
defer th.App.PermanentDeleteUser(&user)
|
||||
|
||||
if _, err = th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err == nil || err.Where != "JoinUserToTeam" {
|
||||
t.Log(err)
|
||||
t.Fatal("Should not add restricted user")
|
||||
}
|
||||
|
||||
user = model.User{Email: strings.ToLower(model.NewId()) + "test@invalid.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), AuthService: "notnil", AuthData: model.NewString("notnil")}
|
||||
ruser, err = th.App.CreateUser(&user)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating authservice user: %s", err)
|
||||
}
|
||||
defer th.App.PermanentDeleteUser(&user)
|
||||
|
||||
if _, err := th.App.AddUserToTeam(th.BasicTeam.Id, ruser.Id, ""); err == nil || err.Where != "JoinUserToTeam" {
|
||||
t.Log(err)
|
||||
t.Fatal("Should not add restricted user")
|
||||
t.Fatal("Should not add authservice user")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user