Class: Trailblazer::Pro::Trace::Signin
- Inherits:
-
Activity::Railway
- Object
- Activity::Railway
- Trailblazer::Pro::Trace::Signin
- Defined in:
- lib/trailblazer/pro/trace/signin.rb
Constant Summary collapse
- PRO_SIGNIN_PATH =
left ->(ctx, response:, **) { puts response.status } # FIXME: better error handling!
"/api/v1/signin_with_api_key"
- SESSION_VARIABLE_NAMES =
DISCUSS: this is the “outgoing” contract, the variables we should store in session_params.
[ #:custom_token, :id_token, :refresh_token, :expires_at, :jwt_token_exp, :firebase_signin_url, :firebase_refresh_url, :firebase_upload_url, :firestore_fields_template ]
Instance Method Summary collapse
- #extract_custom_token(ctx, parsed_response:) ⇒ Object
- #extract_data_for_firebase(ctx, parsed_response:) ⇒ Object
- #extract_id_token(ctx, parsed_response:) ⇒ Object
- #extract_refresh_token(ctx, parsed_response:) ⇒ Object
-
#request_custom_token(ctx, http: Faraday, api_key:, trailblazer_pro_host: "https://pro.trailblazer.to") ⇒ Object
DISCUSS: do we like the defaulting?.
- #request_id_token(ctx, http: Faraday, firebase_signin_url:, custom_token:) ⇒ Object
Instance Method Details
#extract_custom_token(ctx, parsed_response:) ⇒ Object
64 65 66 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 64 def extract_custom_token(ctx, parsed_response:, **) ctx[:custom_token] = parsed_response["custom_token"] end |
#extract_data_for_firebase(ctx, parsed_response:) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 68 def extract_data_for_firebase(ctx, parsed_response:, **) ctx[:firebase_signin_url] = parsed_response["firebase_signin_url"] or return ctx[:firebase_refresh_url] = parsed_response["firebase_refresh_url"] or return ctx[:firebase_upload_url] = parsed_response["firebase_upload_url"] or return # needed in {Trace::Store}. ctx[:firestore_fields_template] = parsed_response["firebase_upload_data"] or return end |
#extract_id_token(ctx, parsed_response:) ⇒ Object
88 89 90 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 88 def extract_id_token(ctx, parsed_response:, **) ctx[:id_token] = parsed_response["idToken"] end |
#extract_refresh_token(ctx, parsed_response:) ⇒ Object
92 93 94 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 92 def extract_refresh_token(ctx, parsed_response:, **) ctx[:refresh_token] = parsed_response["refreshToken"] end |
#request_custom_token(ctx, http: Faraday, api_key:, trailblazer_pro_host: "https://pro.trailblazer.to") ⇒ Object
DISCUSS: do we like the defaulting?
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 52 def request_custom_token(ctx, http: Faraday, api_key:, trailblazer_pro_host: "https://pro.trailblazer.to", **) # DISCUSS: do we like the defaulting? ctx[:response] = http.post( "#{trailblazer_pro_host}#{PRO_SIGNIN_PATH}", { api_key: api_key, }.to_json, {'Content-Type'=>'application/json', "Accept": "application/json"} ) ctx[:response].status == 200 end |
#request_id_token(ctx, http: Faraday, firebase_signin_url:, custom_token:) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/trailblazer/pro/trace/signin.rb', line 75 def request_id_token(ctx, http: Faraday, firebase_signin_url:, custom_token:, **) ctx[:response] = http.post( firebase_signin_url, { token: custom_token, returnSecureToken: true }.to_json, {'Content-Type'=>'application/json', "Accept": "application/json"} ) ctx[:response].status == 200 end |