[MM-13891] Enable team domain restriction for AuthService users (#10209)
* Enable team domain restriction for AuthService users * govet
Этот коммит содержится в:
коммит произвёл
Carlos Tadeu Panato Junior
родитель
46b05499cc
Коммит
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 {
|
func (a *App) isTeamEmailAllowed(user *model.User, team *model.Team) bool {
|
||||||
email := strings.ToLower(user.Email)
|
email := strings.ToLower(user.Email)
|
||||||
|
|
||||||
if len(user.AuthService) > 0 && len(*user.AuthData) > 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.isTeamEmailAddressAllowed(email, team.AllowedDomains)
|
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: ""}
|
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)
|
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 restricted user")
|
t.Fatal("Should not add authservice user")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user