handlers/connector_login: check before update (optimization)
Signed-off-by: Stephan Renatus <srenatus@chef.io>
This commit is contained in:
parent
f18d7afc6f
commit
f013a44581
@ -224,14 +224,16 @@ func (s *Server) handleConnectorLogin(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the connector being used for the login.
|
// Set the connector being used for the login.
|
||||||
updater := func(a storage.AuthRequest) (storage.AuthRequest, error) {
|
if authReq.ConnectorID != connID {
|
||||||
a.ConnectorID = connID
|
updater := func(a storage.AuthRequest) (storage.AuthRequest, error) {
|
||||||
return a, nil
|
a.ConnectorID = connID
|
||||||
}
|
return a, nil
|
||||||
if err := s.storage.UpdateAuthRequest(authReqID, updater); err != nil {
|
}
|
||||||
s.logger.Errorf("Failed to set connector ID on auth request: %v", err)
|
if err := s.storage.UpdateAuthRequest(authReqID, updater); err != nil {
|
||||||
s.renderError(w, http.StatusInternalServerError, "Database error.")
|
s.logger.Errorf("Failed to set connector ID on auth request: %v", err)
|
||||||
return
|
s.renderError(w, http.StatusInternalServerError, "Database error.")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scopes := parseScopes(authReq.Scopes)
|
scopes := parseScopes(authReq.Scopes)
|
||||||
|
Reference in New Issue
Block a user