From 227586e09af8c1ad1466a72078e5644d8368797f Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Thu, 29 Jun 2017 15:04:14 +0200 Subject: [PLT-5639] Show a message when invited addresses are blocked (#6691) * Show a message when invited addresses are blocked When using the "Send Email Invite" functionality. Emails were sent to domains that were not on the `RestrictCreationToDomains` list. This would lead to users getting a message that they can't create an account if they follow the link in the email. This commit will check the email addresses before the mails are sent and warn the user typing them in which ones are blocked. * Add unit test for domain restrictions on invite * Invite Member: Clear serverError on toggle --- api4/team_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'api4') diff --git a/api4/team_test.go b/api4/team_test.go index e62790173..665db95f5 100644 --- a/api4/team_test.go +++ b/api4/team_test.go @@ -1449,6 +1449,22 @@ func TestInviteUsersToTeam(t *testing.T) { } } } + + restrictCreationToDomains := utils.Cfg.TeamSettings.RestrictCreationToDomains + defer func() { + utils.Cfg.TeamSettings.RestrictCreationToDomains = restrictCreationToDomains + }() + utils.Cfg.TeamSettings.RestrictCreationToDomains = "@example.com" + + err := app.InviteNewUsersToTeam(emailList, th.BasicTeam.Id, th.BasicUser.Id) + + if err == nil { + t.Fatal("Adding users with non-restricted domains was allowed") + } + if err.Where != "InviteNewUsersToTeam" || err.Message != "api.team.invite_members.invalid_email.app_error" { + t.Log(err) + t.Fatal("Got wrong error message!") + } } func TestGetTeamInviteInfo(t *testing.T) { -- cgit v1.2.3-1-g7c22