Module: GraphqlDevise::AdditionalControllerMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/graphql_devise/concerns/additional_controller_methods.rb
Instance Method Summary collapse
- #authenticate_model(*models) ⇒ Object
- #build_redirect_headers(access_token, client, redirect_header_options = {}) ⇒ Object
- #gql_devise_context(*models) ⇒ Object
- #resource_class(resource = nil) ⇒ Object
- #set_resource_by_token(resource) ⇒ Object
Instance Method Details
#authenticate_model(*models) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/graphql_devise/concerns/additional_controller_methods.rb', line 18 def authenticate_model(*models) models.each do |model| set_resource_by_token(model) return @resource if @resource.present? end nil end |
#build_redirect_headers(access_token, client, redirect_header_options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/graphql_devise/concerns/additional_controller_methods.rb', line 38 def build_redirect_headers(access_token, client, = {}) { DeviseTokenAuth.headers_names[:'access-token'] => access_token, DeviseTokenAuth.headers_names[:client] => client, :config => params[:config], :client_id => client, :token => access_token }.merge() end |
#gql_devise_context(*models) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/graphql_devise/concerns/additional_controller_methods.rb', line 11 def gql_devise_context(*models) { current_resource: authenticate_model(*models), controller: self } end |
#resource_class(resource = nil) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/graphql_devise/concerns/additional_controller_methods.rb', line 27 def resource_class(resource = nil) # Return the resource class instead of looking for a Devise mapping if resource is already a resource class return resource if resource.respond_to?(:find_by) super end |
#set_resource_by_token(resource) ⇒ Object
34 35 36 |
# File 'lib/graphql_devise/concerns/additional_controller_methods.rb', line 34 def set_resource_by_token(resource) set_user_by_token(resource) end |