[MM-25568] LDAP Sync skip users and log when they dont match the restricted email of a team or channel (#14895)

* Dont return an error if createDefaultChannelMemberships fails due to email domain restriction on team

* Add test ensuring sync works as intended and only skips over failed users

* Remove unneeded line

* Update wording

* Trigger CI
Этот коммит содержится в:
Farhan Munshi
2020-06-29 10:42:03 -04:00
коммит произвёл GitHub
родитель d3156395a1
Коммит 9e12a34e3c
2 изменённых файлов: 57 добавлений и 0 удалений

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

@@ -36,6 +36,14 @@ func (a *App) createDefaultChannelMemberships(since int64, channelID *string) er
if tmem == nil {
_, err = a.AddTeamMember(channel.TeamId, userChannel.UserID)
if err != nil {
if err.Id == "api.team.join_user_to_team.allowed_domains.app_error" {
a.Log().Info("User not added to channel - the domain associated with the user is not in the list of allowed team domains",
mlog.String("user_id", userChannel.UserID),
mlog.String("channel_id", userChannel.ChannelID),
mlog.String("team_id", channel.TeamId),
)
continue
}
return err
}
a.Log().Info("added teammember",
@@ -77,6 +85,13 @@ func (a *App) createDefaultTeamMemberships(since int64, teamID *string) error {
for _, userTeam := range teamMembers {
_, err := a.AddTeamMember(userTeam.TeamID, userTeam.UserID)
if err != nil {
if err.Id == "api.team.join_user_to_team.allowed_domains.app_error" {
a.Log().Info("User not added to team - the domain associated with the user is not in the list of allowed team domains",
mlog.String("user_id", userTeam.UserID),
mlog.String("team_id", userTeam.TeamID),
)
continue
}
return err
}