loadFlowState parses the `state` query parameter as a UUID, loads the flow state from the database, and extracts the provider requested
(w http.ResponseWriter, r *http.Request)
| 29 | // loadFlowState parses the `state` query parameter as a UUID, |
| 30 | // loads the flow state from the database, and extracts the provider requested |
| 31 | func (a *API) loadFlowState(w http.ResponseWriter, r *http.Request) (context.Context, error) { |
| 32 | ctx := r.Context() |
| 33 | db := a.db.WithContext(ctx) |
| 34 | |
| 35 | oauthToken := r.URL.Query().Get("oauth_token") |
| 36 | if oauthToken != "" { |
| 37 | ctx = withRequestToken(ctx, oauthToken) |
| 38 | } |
| 39 | oauthVerifier := r.URL.Query().Get("oauth_verifier") |
| 40 | if oauthVerifier != "" { |
| 41 | ctx = withOAuthVerifier(ctx, oauthVerifier) |
| 42 | } |
| 43 | |
| 44 | var err error |
| 45 | ctx, err = a.loadExternalState(ctx, r, db) |
| 46 | if err != nil { |
| 47 | u, uerr := url.ParseRequestURI(a.config.SiteURL) |
| 48 | if uerr != nil { |
| 49 | return ctx, apierrors.NewInternalServerError("site url is improperly formatted").WithInternalError(uerr) |
| 50 | } |
| 51 | |
| 52 | q := getErrorQueryString(err, utilities.GetRequestID(ctx), observability.GetLogEntry(r).Entry, u.Query()) |
| 53 | u.RawQuery = q.Encode() |
| 54 | |
| 55 | http.Redirect(w, r, u.String(), http.StatusSeeOther) |
| 56 | } |
| 57 | return ctx, err |
| 58 | } |
| 59 | |
| 60 | func (a *API) oAuthCallback(ctx context.Context, r *http.Request, providerType string) (*OAuthProviderData, error) { |
| 61 | db := a.db.WithContext(ctx) |
nothing calls this directly
no test coverage detected