From faaac9cb7437abf13a55f5b2af8578b6f5574e50 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Wed, 25 Nov 2020 19:01:32 +0530 Subject: [PATCH] MM-30861: Fix racy test TestSaml2Login (#16376) * MM-30861: Fix racy test TestSaml2Login https://mattermost.atlassian.net/browse/MM-30861 ```release-note NONE ``` * incorporate suggestions Co-authored-by: Mattermod --- web/saml.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/web/saml.go b/web/saml.go index a16295ab3e..795879c3cc 100644 --- a/web/saml.go +++ b/web/saml.go @@ -117,15 +117,12 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) { switch action { case model.OAUTH_ACTION_SIGNUP: - teamId := relayProps["team_id"] - if len(teamId) > 0 { - c.App.Srv().Go(func() { - if err = c.App.AddUserToTeamByTeamId(teamId, user); err != nil { - mlog.Error(err.Error()) - } else { - c.App.AddDirectChannels(teamId, user) - } - }) + if teamId := relayProps["team_id"]; teamId != "" { + if err = c.App.AddUserToTeamByTeamId(teamId, user); err != nil { + mlog.Error(err.Error()) + break + } + c.App.AddDirectChannels(teamId, user) } case model.OAUTH_ACTION_EMAIL_TO_SSO: if err = c.App.RevokeAllSessions(user.Id); err != nil {