From 3425aa3e5d814e0c6d377a7faa07de6451216be1 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Wed, 3 Feb 2016 10:32:37 -0500 Subject: Update user email when switching to SSO --- api/user.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'api') diff --git a/api/user.go b/api/user.go index 91c8c022a..8b2df7143 100644 --- a/api/user.go +++ b/api/user.go @@ -2087,13 +2087,16 @@ func switchToSSO(c *Context, w http.ResponseWriter, r *http.Request) { func CompleteSwitchWithOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, team *model.Team, email string) { authData := "" + ssoEmail := "" provider := einterfaces.GetOauthProvider(service) if provider == nil { c.Err = model.NewLocAppError("CompleteClaimWithOAuth", "api.user.complete_switch_with_oauth.unavailable.app_error", map[string]interface{}{"Service": service}, "") return } else { - authData = provider.GetAuthDataFromJson(userData) + ssoUser := provider.GetUserFromJson(userData) + authData = ssoUser.AuthData + ssoEmail = ssoUser.Email } if len(authData) == 0 { @@ -2120,7 +2123,7 @@ func CompleteSwitchWithOAuth(c *Context, w http.ResponseWriter, r *http.Request, return } - if result := <-Srv.Store.User().UpdateAuthData(user.Id, service, authData); result.Err != nil { + if result := <-Srv.Store.User().UpdateAuthData(user.Id, service, authData, ssoEmail); result.Err != nil { c.Err = result.Err return } -- cgit v1.2.3-1-g7c22