Module: PadlockAuth::Rails::ActionCableChannelHelpers::TokenFactory
- Defined in:
- lib/padlock_auth/rails/action_cable_channel_helpers.rb
Class Method Summary collapse
-
.authenticate(params) ⇒ Object
Retreives the access token from the params, and builds an access token object.
-
.from_access_token_param(params) ⇒ String?
Extracts the access token from the ‘access_token` parameter.
-
.from_bearer_param(params) ⇒ String?
Extracts the access token from the ‘bearer_token` parameter.
-
.from_params(params, *methods) ⇒ Object
Retreives the access token from the request using the configured methods.
Class Method Details
.authenticate(params) ⇒ Object
Retreives the access token from the params, and builds an access token object.
17 18 19 20 21 |
# File 'lib/padlock_auth/rails/action_cable_channel_helpers.rb', line 17 def authenticate(params) if (token = from_params(params, *PadlockAuth.config.action_cable_methods)) PadlockAuth.build_access_token(token) end end |
.from_access_token_param(params) ⇒ String?
Extracts the access token from the ‘access_token` parameter.
29 30 31 |
# File 'lib/padlock_auth/rails/action_cable_channel_helpers.rb', line 29 def from_access_token_param(params) params[:access_token] end |
.from_bearer_param(params) ⇒ String?
Extracts the access token from the ‘bearer_token` parameter.
39 40 41 |
# File 'lib/padlock_auth/rails/action_cable_channel_helpers.rb', line 39 def from_bearer_param(params) params[:bearer_token] end |
.from_params(params, *methods) ⇒ Object
Retreives the access token from the request using the configured methods.
8 9 10 11 12 13 14 |
# File 'lib/padlock_auth/rails/action_cable_channel_helpers.rb', line 8 def from_params(params, *methods) methods.inject(nil) do |_, method| method = self.method(method) if method.is_a?(Symbol) credentials = method.call(params) break credentials if credentials.present? end end |