authenticate: remove extra UpdateUserInfo() call

The buildIdentityProfile() method is called only from
Authenticate.getOAuthCallback(), which has previously called
Authenticator.Authenticate(). It looks like all implementations of the
Authenticator interface already call UpdateUserInfo(), so we shouldn't
need to call UpdateUserInfo() a second time from buildIdentityProfile().

This should simplify the code a little and provide a slight performance
improvement (by avoiding one network request).
This commit is contained in:
Kenneth Jenkins 2023-12-04 12:41:19 -08:00
parent 1780fefa72
commit 59447ca039

View file

@ -29,19 +29,8 @@ func (a *Authenticate) buildIdentityProfile(
claims identity.SessionClaims,
oauthToken *oauth2.Token,
) (*identitypb.Profile, error) {
options := a.options.Load()
idpID := r.FormValue(urlutil.QueryIdentityProviderID)
authenticator, err := a.cfg.getIdentityProvider(options, idpID)
if err != nil {
return nil, fmt.Errorf("authenticate: error getting identity provider authenticator: %w", err)
}
err = authenticator.UpdateUserInfo(ctx, oauthToken, &claims)
if err != nil {
return nil, fmt.Errorf("authenticate: error retrieving user info: %w", err)
}
rawIDToken := []byte(claims.RawIDToken)
rawOAuthToken, err := json.Marshal(oauthToken)
if err != nil {