graphql_devise 0.18.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -2
- data/.gitignore +4 -0
- data/.rubocop.yml +9 -10
- data/Appraisals +72 -35
- data/CHANGELOG.md +63 -0
- data/README.md +71 -142
- data/app/controllers/graphql_devise/graphql_controller.rb +3 -3
- data/app/views/graphql_devise/mailer/confirmation_instructions.html.erb +1 -5
- data/config/routes.rb +0 -2
- data/graphql_devise.gemspec +8 -6
- data/lib/generators/graphql_devise/install_generator.rb +1 -1
- data/lib/graphql_devise/concerns/additional_controller_methods.rb +48 -0
- data/lib/graphql_devise/concerns/additional_model_methods.rb +17 -0
- data/lib/graphql_devise/concerns/authenticatable.rb +1 -1
- data/lib/graphql_devise/concerns/controller_methods.rb +79 -91
- data/lib/graphql_devise/concerns/field_authentication.rb +14 -0
- data/lib/graphql_devise/concerns/set_user_by_token.rb +1 -1
- data/lib/graphql_devise/default_operations.rb +16 -0
- data/lib/graphql_devise/engine.rb +0 -2
- data/lib/graphql_devise/model/with_email_updater.rb +5 -30
- data/lib/graphql_devise/mount_method/operation_preparer.rb +0 -7
- data/lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb +1 -1
- data/lib/graphql_devise/mount_method/operation_preparers/default_operation_preparer.rb +1 -1
- data/lib/graphql_devise/mount_method/operation_sanitizer.rb +0 -12
- data/lib/graphql_devise/mount_method/option_sanitizer.rb +0 -2
- data/lib/graphql_devise/mount_method/option_sanitizers/array_checker.rb +2 -2
- data/lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb +2 -2
- data/lib/graphql_devise/mount_method/option_sanitizers/hash_checker.rb +1 -1
- data/lib/graphql_devise/mount_method/option_sanitizers/string_checker.rb +1 -1
- data/lib/graphql_devise/mount_method/option_validators/provided_operations_validator.rb +0 -2
- data/lib/graphql_devise/mount_method/option_validators/skip_only_validator.rb +1 -1
- data/lib/graphql_devise/mount_method/option_validators/supported_operations_validator.rb +1 -1
- data/lib/graphql_devise/mount_method/options_validator.rb +0 -3
- data/lib/graphql_devise/mount_method/supported_options.rb +0 -5
- data/lib/graphql_devise/mutations/base.rb +1 -1
- data/lib/graphql_devise/mutations/confirm_registration_with_token.rb +2 -2
- data/lib/graphql_devise/mutations/login.rb +2 -2
- data/lib/graphql_devise/mutations/register.rb +2 -2
- data/lib/graphql_devise/mutations/update_password_with_token.rb +2 -2
- data/lib/graphql_devise/resolvers/base.rb +1 -1
- data/lib/graphql_devise/resource_loader.rb +71 -39
- data/lib/graphql_devise/route_mounter.rb +13 -0
- data/lib/graphql_devise/schema_plugin.rb +11 -40
- data/lib/graphql_devise/types/authenticatable_type.rb +1 -1
- data/lib/graphql_devise/types/base_field.rb +9 -0
- data/lib/graphql_devise/types/base_type.rb +8 -0
- data/lib/graphql_devise/types/credential_type.rb +1 -1
- data/lib/graphql_devise/types/mutation_type.rb +1 -0
- data/lib/graphql_devise/types/query_type.rb +1 -0
- data/lib/graphql_devise/version.rb +1 -1
- data/lib/graphql_devise.rb +21 -29
- data/spec/dummy/app/controllers/api/v1/graphql_controller.rb +2 -16
- data/spec/dummy/app/graphql/dummy_schema.rb +1 -5
- data/spec/dummy/app/graphql/interpreter_schema.rb +6 -2
- data/spec/dummy/app/graphql/mutations/base_mutation.rb +6 -0
- data/spec/dummy/app/graphql/mutations/update_user.rb +2 -4
- data/spec/dummy/app/graphql/types/admin_type.rb +1 -1
- data/spec/dummy/app/graphql/types/custom_admin_type.rb +1 -1
- data/spec/dummy/app/graphql/types/mutation_type.rb +3 -1
- data/spec/dummy/app/graphql/types/query_type.rb +3 -1
- data/spec/dummy/app/graphql/types/user_type.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/routes.rb +5 -9
- data/spec/generators/graphql_devise/install_generator_spec.rb +2 -2
- data/spec/graphql_devise/model/with_email_updater_spec.rb +17 -35
- data/spec/rails_helper.rb +5 -5
- data/spec/requests/mutations/login_spec.rb +34 -0
- data/spec/requests/mutations/resend_confirmation_with_token_spec.rb +2 -3
- data/spec/requests/user_controller_spec.rb +1 -33
- data/spec/services/resource_loader_spec.rb +53 -3
- data/spec/spec_helper.rb +1 -1
- metadata +62 -55
- data/app/controllers/graphql_devise/concerns/additional_controller_methods.rb +0 -72
- data/app/controllers/graphql_devise/concerns/set_user_by_token.rb +0 -21
- data/app/helpers/graphql_devise/mailer_helper.rb +0 -37
- data/app/models/graphql_devise/concerns/additional_model_methods.rb +0 -21
- data/app/models/graphql_devise/concerns/model.rb +0 -25
- data/lib/graphql_devise/default_operations/mutations.rb +0 -32
- data/lib/graphql_devise/default_operations/resolvers.rb +0 -14
- data/lib/graphql_devise/mutations/resend_confirmation.rb +0 -45
- data/lib/graphql_devise/mutations/send_password_reset.rb +0 -38
- data/lib/graphql_devise/mutations/sign_up.rb +0 -61
- data/lib/graphql_devise/mutations/update_password.rb +0 -46
- data/lib/graphql_devise/rails/routes.rb +0 -15
- data/lib/graphql_devise/resolvers/check_password_token.rb +0 -43
- data/lib/graphql_devise/resolvers/confirm_account.rb +0 -42
- data/spec/dummy/app/graphql/mutations/sign_up.rb +0 -14
- data/spec/dummy/app/graphql/resolvers/confirm_admin_account.rb +0 -13
- data/spec/requests/mutations/resend_confirmation_spec.rb +0 -153
- data/spec/requests/mutations/send_password_reset_spec.rb +0 -103
- data/spec/requests/mutations/sign_up_spec.rb +0 -170
- data/spec/requests/mutations/update_password_spec.rb +0 -116
- data/spec/requests/queries/check_password_token_spec.rb +0 -149
- data/spec/requests/queries/confirm_account_spec.rb +0 -137
@@ -1,122 +1,110 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GraphqlDevise
|
4
|
-
module
|
5
|
-
|
6
|
-
extend ActiveSupport::Concern
|
4
|
+
module ControllerMethods
|
5
|
+
extend ActiveSupport::Concern
|
7
6
|
|
8
|
-
|
7
|
+
private
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def raise_user_error(message)
|
17
|
-
raise GraphqlDevise::UserError, message
|
9
|
+
def check_redirect_url_whitelist!(redirect_url)
|
10
|
+
if blacklisted_redirect_url?(redirect_url)
|
11
|
+
raise_user_error(I18n.t('graphql_devise.redirect_url_not_allowed', redirect_url: redirect_url))
|
18
12
|
end
|
13
|
+
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
def raise_user_error(message)
|
16
|
+
raise UserError, message
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
controller.token = nil
|
28
|
-
end
|
19
|
+
def raise_user_error_list(message, errors:)
|
20
|
+
raise DetailedUserError.new(message, errors: errors)
|
21
|
+
end
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
def remove_resource
|
24
|
+
controller.resource = nil
|
25
|
+
controller.client_id = nil
|
26
|
+
controller.token = nil
|
27
|
+
end
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
def response
|
30
|
+
controller.response
|
31
|
+
end
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
def controller
|
34
|
+
context[:controller]
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
def resource_name
|
38
|
+
::GraphqlDevise.to_mapping_name(resource_class)
|
39
|
+
end
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
def resource_class
|
42
|
+
self.class.instance_variable_get(:@resource_klass)
|
43
|
+
end
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
def recoverable_enabled?
|
46
|
+
resource_class.devise_modules.include?(:recoverable)
|
47
|
+
end
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
def confirmable_enabled?
|
50
|
+
resource_class.devise_modules.include?(:confirmable)
|
51
|
+
end
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
def blacklisted_redirect_url?(redirect_url)
|
54
|
+
DeviseTokenAuth.redirect_whitelist && !DeviseTokenAuth::Url.whitelisted?(redirect_url)
|
55
|
+
end
|
61
56
|
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
def current_resource
|
58
|
+
@current_resource ||= controller.send(:set_resource_by_token, resource_class)
|
59
|
+
end
|
65
60
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
61
|
+
def client
|
62
|
+
if Gem::Version.new(DeviseTokenAuth::VERSION) <= Gem::Version.new('1.1.0')
|
63
|
+
controller.client_id
|
64
|
+
else
|
65
|
+
controller.token.client if controller.token.present?
|
72
66
|
end
|
67
|
+
end
|
73
68
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
69
|
+
def generate_auth_headers(resource)
|
70
|
+
auth_headers = resource.create_new_auth_token
|
71
|
+
controller.resource = resource
|
72
|
+
access_token_name = DeviseTokenAuth.headers_names[:'access-token']
|
73
|
+
client_name = DeviseTokenAuth.headers_names[:'client']
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
75
|
+
# NOTE: Depending on the DTA version, the token will be an object or nil
|
76
|
+
if controller.token
|
77
|
+
controller.token.client = auth_headers[client_name]
|
78
|
+
controller.token.token = auth_headers[access_token_name]
|
79
|
+
else
|
80
|
+
controller.client_id = auth_headers[client_name]
|
81
|
+
controller.token = auth_headers[access_token_name]
|
87
82
|
end
|
88
83
|
|
89
|
-
|
90
|
-
|
91
|
-
:build_redirect_headers,
|
92
|
-
token_info.fetch(:token),
|
93
|
-
token_info.fetch(:client_id),
|
94
|
-
redirect_header_options
|
95
|
-
)
|
96
|
-
end
|
84
|
+
auth_headers
|
85
|
+
end
|
97
86
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
87
|
+
def find_resource(field, value)
|
88
|
+
if resource_class.connection.adapter_name.downcase.include?('mysql')
|
89
|
+
# fix for mysql default case insensitivity
|
90
|
+
resource_class.where("BINARY #{field} = ? AND provider= ?", value, provider).first
|
91
|
+
elsif Gem::Version.new(DeviseTokenAuth::VERSION) < Gem::Version.new('1.1.0')
|
92
|
+
resource_class.find_by(field => value, :provider => provider)
|
93
|
+
else
|
94
|
+
resource_class.dta_find_by(field => value, :provider => provider)
|
107
95
|
end
|
96
|
+
end
|
108
97
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
98
|
+
def get_case_insensitive_field(field, value)
|
99
|
+
if resource_class.case_insensitive_keys.include?(field)
|
100
|
+
value.downcase
|
101
|
+
else
|
102
|
+
value
|
115
103
|
end
|
104
|
+
end
|
116
105
|
|
117
|
-
|
118
|
-
|
119
|
-
end
|
106
|
+
def provider
|
107
|
+
:email
|
120
108
|
end
|
121
109
|
end
|
122
110
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphqlDevise
|
4
|
+
module FieldAuthentication
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def initialize(*args, authenticate: nil, **kwargs, &block)
|
8
|
+
@authenticate = authenticate
|
9
|
+
super(*args, **kwargs, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :authenticate
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphqlDevise
|
4
|
+
module DefaultOperations
|
5
|
+
QUERIES = {}.freeze
|
6
|
+
MUTATIONS = {
|
7
|
+
login: { klass: Mutations::Login, authenticatable: true },
|
8
|
+
logout: { klass: Mutations::Logout, authenticatable: true },
|
9
|
+
register: { klass: Mutations::Register, authenticatable: true },
|
10
|
+
update_password_with_token: { klass: Mutations::UpdatePasswordWithToken, authenticatable: true },
|
11
|
+
send_password_reset_with_token: { klass: Mutations::SendPasswordResetWithToken, authenticatable: false },
|
12
|
+
resend_confirmation_with_token: { klass: Mutations::ResendConfirmationWithToken, authenticatable: false },
|
13
|
+
confirm_registration_with_token: { klass: Mutations::ConfirmRegistrationWithToken, authenticatable: true }
|
14
|
+
}.freeze
|
15
|
+
end
|
16
|
+
end
|
@@ -9,15 +9,13 @@ module GraphqlDevise
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
-
|
13
|
-
|
14
|
-
resource_attributes = @attributes.except(:schema_url, :confirmation_success_url, :confirmation_url)
|
12
|
+
resource_attributes = @attributes.except(:confirmation_url)
|
15
13
|
return @resource.update(resource_attributes) unless requires_reconfirmation?(resource_attributes)
|
16
14
|
|
17
15
|
@resource.assign_attributes(resource_attributes)
|
18
16
|
|
19
17
|
if @resource.email == email_in_database
|
20
|
-
|
18
|
+
@resource.save
|
21
19
|
elsif required_reconfirm_attributes?
|
22
20
|
return false unless @resource.valid?
|
23
21
|
|
@@ -28,7 +26,7 @@ module GraphqlDevise
|
|
28
26
|
saved
|
29
27
|
else
|
30
28
|
raise(
|
31
|
-
GraphqlDevise::Error,
|
29
|
+
::GraphqlDevise::Error,
|
32
30
|
'Method `update_with_email` requires attribute `confirmation_url` for email reconfirmation to work'
|
33
31
|
)
|
34
32
|
end
|
@@ -36,24 +34,8 @@ module GraphqlDevise
|
|
36
34
|
|
37
35
|
private
|
38
36
|
|
39
|
-
def check_deprecated_attributes
|
40
|
-
if [@attributes[:schema_url], @attributes[:confirmation_success_url]].any?(&:present?)
|
41
|
-
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
42
|
-
Providing `schema_url` and `confirmation_success_url` to `update_with_email` is deprecated and will be
|
43
|
-
removed in a future version of this gem.
|
44
|
-
|
45
|
-
Now you must only provide `confirmation_url` and the email will contain the new format of the confirmation
|
46
|
-
url that needs to be used with the new `confirmRegistrationWithToken` on the client application.
|
47
|
-
DEPRECATION
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
37
|
def required_reconfirm_attributes?
|
52
|
-
|
53
|
-
[@attributes[:confirmation_success_url], DeviseTokenAuth.default_confirm_success_url].any?(&:present?)
|
54
|
-
else
|
55
|
-
[@attributes[:confirmation_url], DeviseTokenAuth.default_confirm_success_url].any?(&:present?)
|
56
|
-
end
|
38
|
+
[@attributes[:confirmation_url], DeviseTokenAuth.default_confirm_success_url].any?(&:present?)
|
57
39
|
end
|
58
40
|
|
59
41
|
def requires_reconfirmation?(resource_attributes)
|
@@ -78,14 +60,7 @@ module GraphqlDevise
|
|
78
60
|
end
|
79
61
|
|
80
62
|
def confirmation_method_params
|
81
|
-
|
82
|
-
{
|
83
|
-
redirect_url: @attributes[:confirmation_success_url] || DeviseTokenAuth.default_confirm_success_url,
|
84
|
-
schema_url: @attributes[:schema_url]
|
85
|
-
}
|
86
|
-
else
|
87
|
-
{ redirect_url: @attributes[:confirmation_url] || DeviseTokenAuth.default_confirm_success_url }
|
88
|
-
end
|
63
|
+
{ redirect_url: @attributes[:confirmation_url] || DeviseTokenAuth.default_confirm_success_url }
|
89
64
|
end
|
90
65
|
|
91
66
|
def send_confirmation_instructions(saved)
|
@@ -1,12 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'operation_preparers/gql_name_setter'
|
4
|
-
require_relative 'operation_preparers/mutation_field_setter'
|
5
|
-
require_relative 'operation_preparers/resolver_type_setter'
|
6
|
-
require_relative 'operation_preparers/resource_klass_setter'
|
7
|
-
require_relative 'operation_preparers/default_operation_preparer'
|
8
|
-
require_relative 'operation_preparers/custom_operation_preparer'
|
9
|
-
|
10
3
|
module GraphqlDevise
|
11
4
|
module MountMethod
|
12
5
|
class OperationPreparer
|
@@ -11,7 +11,7 @@ module GraphqlDevise
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
mapping_name = GraphqlDevise.to_mapping_name(@model)
|
14
|
+
mapping_name = ::GraphqlDevise.to_mapping_name(@model)
|
15
15
|
|
16
16
|
@custom_operations.slice(*@selected_keys).each_with_object({}) do |(action, operation), result|
|
17
17
|
mapped_action = "#{mapping_name}_#{action}"
|
@@ -12,7 +12,7 @@ module GraphqlDevise
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
mapping_name = GraphqlDevise.to_mapping_name(@model)
|
15
|
+
mapping_name = ::GraphqlDevise.to_mapping_name(@model)
|
16
16
|
|
17
17
|
@selected_operations.except(*@custom_keys).each_with_object({}) do |(action, operation_info), result|
|
18
18
|
mapped_action = "#{mapping_name}_#{action}"
|
@@ -25,18 +25,6 @@ module GraphqlDevise
|
|
25
25
|
else
|
26
26
|
@default
|
27
27
|
end
|
28
|
-
|
29
|
-
operations.each do |operation, values|
|
30
|
-
next if values[:deprecation_reason].blank?
|
31
|
-
|
32
|
-
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
33
|
-
`#{operation}` is deprecated and will be removed in a future version of this gem.
|
34
|
-
#{values[:deprecation_reason]}
|
35
|
-
|
36
|
-
You can supress this message by skipping `#{operation}` on your ResourceLoader or the
|
37
|
-
mount_graphql_devise_for method on your routes file.
|
38
|
-
DEPRECATION
|
39
|
-
end
|
40
28
|
end
|
41
29
|
end
|
42
30
|
end
|
@@ -13,11 +13,11 @@ module GraphqlDevise
|
|
13
13
|
return @default_value if value.blank?
|
14
14
|
|
15
15
|
unless value.instance_of?(Array)
|
16
|
-
raise
|
16
|
+
raise InvalidMountOptionsError, "`#{key}` option has an invalid value. Array expected."
|
17
17
|
end
|
18
18
|
|
19
19
|
unless value.all? { |element| element.instance_of?(@element_type) }
|
20
|
-
raise
|
20
|
+
raise InvalidMountOptionsError, "`#{key}` option has invalid elements. #{@element_type} expected."
|
21
21
|
end
|
22
22
|
|
23
23
|
value
|
@@ -12,11 +12,11 @@ module GraphqlDevise
|
|
12
12
|
return if value.nil?
|
13
13
|
|
14
14
|
unless value.instance_of?(Class)
|
15
|
-
raise
|
15
|
+
raise InvalidMountOptionsError, "`#{key}` option has an invalid value. Class expected."
|
16
16
|
end
|
17
17
|
|
18
18
|
unless @klass_array.any? { |klass| value.ancestors.include?(klass) }
|
19
|
-
raise
|
19
|
+
raise InvalidMountOptionsError,
|
20
20
|
"`#{key}` option has an invalid value. #{@klass_array.join(', ')} or descendants expected. Got #{value}."
|
21
21
|
end
|
22
22
|
|
@@ -13,7 +13,7 @@ module GraphqlDevise
|
|
13
13
|
return @default_value if value.blank?
|
14
14
|
|
15
15
|
unless value.instance_of?(Hash)
|
16
|
-
raise
|
16
|
+
raise InvalidMountOptionsError, "`#{key}` option has an invalid value. Hash expected. Got #{value.class}."
|
17
17
|
end
|
18
18
|
|
19
19
|
value.each { |internal_key, klass| ClassChecker.new(@element_type_array).call!(klass, "#{key} -> #{internal_key}") }
|
@@ -12,7 +12,7 @@ module GraphqlDevise
|
|
12
12
|
return @default_string if value.blank?
|
13
13
|
|
14
14
|
unless value.instance_of?(String)
|
15
|
-
raise
|
15
|
+
raise InvalidMountOptionsError, "`#{key}` option has an invalid value. String expected."
|
16
16
|
end
|
17
17
|
|
18
18
|
value
|
@@ -11,7 +11,7 @@ module GraphqlDevise
|
|
11
11
|
def validate!
|
12
12
|
if [@options.skip, @options.only].all?(&:present?)
|
13
13
|
raise(
|
14
|
-
|
14
|
+
InvalidMountOptionsError,
|
15
15
|
"Can't specify both `skip` and `only` options when mounting the route."
|
16
16
|
)
|
17
17
|
end
|
@@ -15,7 +15,7 @@ module GraphqlDevise
|
|
15
15
|
|
16
16
|
if unsupported_operations.present?
|
17
17
|
raise(
|
18
|
-
|
18
|
+
InvalidMountOptionsError,
|
19
19
|
"#{@key} option contains unsupported operations: \"#{unsupported_operations.join(', ')}\". Check for typos."
|
20
20
|
)
|
21
21
|
end
|
@@ -1,10 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'option_sanitizers/array_checker'
|
4
|
-
require_relative 'option_sanitizers/hash_checker'
|
5
|
-
require_relative 'option_sanitizers/string_checker'
|
6
|
-
require_relative 'option_sanitizers/class_checker'
|
7
|
-
|
8
3
|
module GraphqlDevise
|
9
4
|
module MountMethod
|
10
5
|
SUPPORTED_OPTIONS = {
|
@@ -6,7 +6,7 @@ module GraphqlDevise
|
|
6
6
|
argument :confirmation_token, String, required: true
|
7
7
|
|
8
8
|
field :credentials,
|
9
|
-
|
9
|
+
Types::CredentialType,
|
10
10
|
null: true,
|
11
11
|
description: 'Authentication credentials. Null unless user is signed in after confirmation.'
|
12
12
|
|
@@ -18,7 +18,7 @@ module GraphqlDevise
|
|
18
18
|
|
19
19
|
response_payload = { authenticatable: resource }
|
20
20
|
|
21
|
-
response_payload[:credentials] =
|
21
|
+
response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?
|
22
22
|
|
23
23
|
response_payload
|
24
24
|
else
|
@@ -6,7 +6,7 @@ module GraphqlDevise
|
|
6
6
|
argument :email, String, required: true
|
7
7
|
argument :password, String, required: true
|
8
8
|
|
9
|
-
field :credentials,
|
9
|
+
field :credentials, Types::CredentialType, null: false
|
10
10
|
|
11
11
|
def resolve(email:, password:)
|
12
12
|
resource = find_resource(
|
@@ -19,7 +19,7 @@ module GraphqlDevise
|
|
19
19
|
raise_user_error(I18n.t('graphql_devise.sessions.bad_credentials'))
|
20
20
|
end
|
21
21
|
|
22
|
-
new_headers =
|
22
|
+
new_headers = generate_auth_headers(resource)
|
23
23
|
controller.sign_in(:user, resource, store: false, bypass: false)
|
24
24
|
|
25
25
|
yield resource if block_given?
|
@@ -9,7 +9,7 @@ module GraphqlDevise
|
|
9
9
|
argument :confirm_url, String, required: false
|
10
10
|
|
11
11
|
field :credentials,
|
12
|
-
|
12
|
+
Types::CredentialType,
|
13
13
|
null: true,
|
14
14
|
description: 'Authentication credentials. Null if after signUp resource is not active for authentication (e.g. Email confirmation required).'
|
15
15
|
|
@@ -38,7 +38,7 @@ module GraphqlDevise
|
|
38
38
|
|
39
39
|
response_payload = { authenticatable: resource }
|
40
40
|
|
41
|
-
response_payload[:credentials] =
|
41
|
+
response_payload[:credentials] = generate_auth_headers(resource) if resource.active_for_authentication?
|
42
42
|
|
43
43
|
response_payload
|
44
44
|
else
|
@@ -8,7 +8,7 @@ module GraphqlDevise
|
|
8
8
|
argument :reset_password_token, String, required: true
|
9
9
|
|
10
10
|
field :credentials,
|
11
|
-
|
11
|
+
Types::CredentialType,
|
12
12
|
null: true,
|
13
13
|
description: 'Authentication credentials. Resource must be signed_in for credentials to be returned.'
|
14
14
|
|
@@ -23,7 +23,7 @@ module GraphqlDevise
|
|
23
23
|
yield resource if block_given?
|
24
24
|
|
25
25
|
response_payload = { authenticatable: resource }
|
26
|
-
response_payload[:credentials] =
|
26
|
+
response_payload[:credentials] = generate_auth_headers(resource) if controller.signed_in?(resource_name)
|
27
27
|
|
28
28
|
response_payload
|
29
29
|
else
|