-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modify gem files structure to match Zeitwerk requeriments * Remove unneeded requires * Remove support for ruby 2.3 * Require rails generator explicitely & avoid constant name clash * Avoid using generators directory as namespace * Address code review comments * Add deprecation messages to legacy concerns and create new ones * Modify generator to use new concerns * Remove namespace of error classes after rebase * Address code review comments
- Loading branch information
Showing
48 changed files
with
317 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ README.md.* | |
|
||
.env | ||
/spec/tmp/config/routes.rb | ||
/.byebug_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
app/controllers/graphql_devise/concerns/additional_controller_methods.rb
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
app/controllers/graphql_devise/concerns/set_user_by_token.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
app/models/graphql_devise/concerns/additional_model_methods.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/graphql_devise/concerns/additional_controller_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module GraphqlDevise | ||
module AdditionalControllerMethods | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
attr_accessor :client_id, :token, :resource | ||
end | ||
|
||
def gql_devise_context(*models) | ||
{ | ||
current_resource: authenticate_model(*models), | ||
controller: self | ||
} | ||
end | ||
|
||
def authenticate_model(*models) | ||
models.each do |model| | ||
set_resource_by_token(model) | ||
return @resource if @resource.present? | ||
end | ||
|
||
nil | ||
end | ||
|
||
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 | ||
|
||
def set_resource_by_token(resource) | ||
set_user_by_token(resource) | ||
end | ||
|
||
def build_redirect_headers(access_token, client, redirect_header_options = {}) | ||
{ | ||
DeviseTokenAuth.headers_names[:"access-token"] => access_token, | ||
DeviseTokenAuth.headers_names[:client] => client, | ||
:config => params[:config], | ||
:client_id => client, | ||
:token => access_token | ||
}.merge(redirect_header_options) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module GraphqlDevise | ||
module Authenticatable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include DeviseTokenAuth::Concerns::User | ||
|
||
::GraphqlDevise.configure_warden_serializer_for_model(self) | ||
end | ||
|
||
class_methods do | ||
def reconfirmable | ||
devise_modules.include?(:confirmable) && column_names.include?('unconfirmed_email') | ||
end | ||
end | ||
|
||
def update_with_email(attributes = {}) | ||
Model::WithEmailUpdater.new(self, attributes).call | ||
end | ||
end | ||
end |
Oops, something went wrong.