graphql_devise 0.18.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +7 -2
- data/.gitignore +3 -0
- data/.rubocop.yml +9 -10
- data/Appraisals +70 -18
- data/CHANGELOG.md +53 -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 +7 -5
- 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 +70 -93
- 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 +1 -1
- data/lib/graphql_devise/mutations/login.rb +1 -1
- data/lib/graphql_devise/mutations/register.rb +1 -1
- data/lib/graphql_devise/mutations/update_password_with_token.rb +1 -1
- 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 +7 -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 +1 -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/graphql_devise/model/with_email_updater_spec.rb +17 -35
- data/spec/rails_helper.rb +5 -5
- 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 +14 -3
- metadata +55 -48
- 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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql_devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Celi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise_token_auth
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: '1.8'
|
41
41
|
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1
|
43
|
+
version: '2.1'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: '1.8'
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1
|
53
|
+
version: '2.1'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: rails
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,6 +71,20 @@ dependencies:
|
|
71
71
|
- - "<"
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '6.2'
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: zeitwerk
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
type: :runtime
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
74
88
|
- !ruby/object:Gem::Dependency
|
75
89
|
name: appraisal
|
76
90
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,44 +229,58 @@ dependencies:
|
|
215
229
|
name: rubocop
|
216
230
|
requirement: !ruby/object:Gem::Requirement
|
217
231
|
requirements:
|
218
|
-
- -
|
232
|
+
- - "<"
|
219
233
|
- !ruby/object:Gem::Version
|
220
|
-
version: 0.
|
234
|
+
version: 0.82.0
|
221
235
|
type: :development
|
222
236
|
prerelease: false
|
223
237
|
version_requirements: !ruby/object:Gem::Requirement
|
224
238
|
requirements:
|
225
|
-
- -
|
239
|
+
- - "<"
|
226
240
|
- !ruby/object:Gem::Version
|
227
|
-
version: 0.
|
241
|
+
version: 0.82.0
|
228
242
|
- !ruby/object:Gem::Dependency
|
229
243
|
name: rubocop-performance
|
230
244
|
requirement: !ruby/object:Gem::Requirement
|
231
245
|
requirements:
|
232
|
-
- - "
|
246
|
+
- - "<"
|
233
247
|
- !ruby/object:Gem::Version
|
234
|
-
version:
|
248
|
+
version: 1.6.0
|
235
249
|
type: :development
|
236
250
|
prerelease: false
|
237
251
|
version_requirements: !ruby/object:Gem::Requirement
|
238
252
|
requirements:
|
239
|
-
- - "
|
253
|
+
- - "<"
|
240
254
|
- !ruby/object:Gem::Version
|
241
|
-
version:
|
255
|
+
version: 1.6.0
|
256
|
+
- !ruby/object:Gem::Dependency
|
257
|
+
name: rubocop-rails
|
258
|
+
requirement: !ruby/object:Gem::Requirement
|
259
|
+
requirements:
|
260
|
+
- - "<"
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: 2.6.0
|
263
|
+
type: :development
|
264
|
+
prerelease: false
|
265
|
+
version_requirements: !ruby/object:Gem::Requirement
|
266
|
+
requirements:
|
267
|
+
- - "<"
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: 2.6.0
|
242
270
|
- !ruby/object:Gem::Dependency
|
243
271
|
name: rubocop-rspec
|
244
272
|
requirement: !ruby/object:Gem::Requirement
|
245
273
|
requirements:
|
246
|
-
- - "
|
274
|
+
- - "<"
|
247
275
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
276
|
+
version: 1.39.0
|
249
277
|
type: :development
|
250
278
|
prerelease: false
|
251
279
|
version_requirements: !ruby/object:Gem::Requirement
|
252
280
|
requirements:
|
253
|
-
- - "
|
281
|
+
- - "<"
|
254
282
|
- !ruby/object:Gem::Version
|
255
|
-
version:
|
283
|
+
version: 1.39.0
|
256
284
|
- !ruby/object:Gem::Dependency
|
257
285
|
name: sqlite3
|
258
286
|
requirement: !ruby/object:Gem::Requirement
|
@@ -289,13 +317,8 @@ files:
|
|
289
317
|
- README.md
|
290
318
|
- Rakefile
|
291
319
|
- app/controllers/graphql_devise/application_controller.rb
|
292
|
-
- app/controllers/graphql_devise/concerns/additional_controller_methods.rb
|
293
|
-
- app/controllers/graphql_devise/concerns/set_user_by_token.rb
|
294
320
|
- app/controllers/graphql_devise/graphql_controller.rb
|
295
321
|
- app/helpers/graphql_devise/application_helper.rb
|
296
|
-
- app/helpers/graphql_devise/mailer_helper.rb
|
297
|
-
- app/models/graphql_devise/concerns/additional_model_methods.rb
|
298
|
-
- app/models/graphql_devise/concerns/model.rb
|
299
322
|
- app/views/.keep
|
300
323
|
- app/views/graphql_devise/mailer/confirmation_instructions.html.erb
|
301
324
|
- app/views/graphql_devise/mailer/reset_password_instructions.html.erb
|
@@ -308,11 +331,13 @@ files:
|
|
308
331
|
- graphql_devise.gemspec
|
309
332
|
- lib/generators/graphql_devise/install_generator.rb
|
310
333
|
- lib/graphql_devise.rb
|
334
|
+
- lib/graphql_devise/concerns/additional_controller_methods.rb
|
335
|
+
- lib/graphql_devise/concerns/additional_model_methods.rb
|
311
336
|
- lib/graphql_devise/concerns/authenticatable.rb
|
312
337
|
- lib/graphql_devise/concerns/controller_methods.rb
|
338
|
+
- lib/graphql_devise/concerns/field_authentication.rb
|
313
339
|
- lib/graphql_devise/concerns/set_user_by_token.rb
|
314
|
-
- lib/graphql_devise/default_operations
|
315
|
-
- lib/graphql_devise/default_operations/resolvers.rb
|
340
|
+
- lib/graphql_devise/default_operations.rb
|
316
341
|
- lib/graphql_devise/engine.rb
|
317
342
|
- lib/graphql_devise/errors/authentication_error.rb
|
318
343
|
- lib/graphql_devise/errors/detailed_user_error.rb
|
@@ -343,22 +368,18 @@ files:
|
|
343
368
|
- lib/graphql_devise/mutations/login.rb
|
344
369
|
- lib/graphql_devise/mutations/logout.rb
|
345
370
|
- lib/graphql_devise/mutations/register.rb
|
346
|
-
- lib/graphql_devise/mutations/resend_confirmation.rb
|
347
371
|
- lib/graphql_devise/mutations/resend_confirmation_with_token.rb
|
348
|
-
- lib/graphql_devise/mutations/send_password_reset.rb
|
349
372
|
- lib/graphql_devise/mutations/send_password_reset_with_token.rb
|
350
|
-
- lib/graphql_devise/mutations/sign_up.rb
|
351
|
-
- lib/graphql_devise/mutations/update_password.rb
|
352
373
|
- lib/graphql_devise/mutations/update_password_with_token.rb
|
353
|
-
- lib/graphql_devise/rails/routes.rb
|
354
374
|
- lib/graphql_devise/resolvers/base.rb
|
355
|
-
- lib/graphql_devise/resolvers/check_password_token.rb
|
356
|
-
- lib/graphql_devise/resolvers/confirm_account.rb
|
357
375
|
- lib/graphql_devise/resolvers/dummy.rb
|
358
376
|
- lib/graphql_devise/resource_loader.rb
|
377
|
+
- lib/graphql_devise/route_mounter.rb
|
359
378
|
- lib/graphql_devise/schema.rb
|
360
379
|
- lib/graphql_devise/schema_plugin.rb
|
361
380
|
- lib/graphql_devise/types/authenticatable_type.rb
|
381
|
+
- lib/graphql_devise/types/base_field.rb
|
382
|
+
- lib/graphql_devise/types/base_type.rb
|
362
383
|
- lib/graphql_devise/types/credential_type.rb
|
363
384
|
- lib/graphql_devise/types/mutation_type.rb
|
364
385
|
- lib/graphql_devise/types/query_type.rb
|
@@ -370,13 +391,12 @@ files:
|
|
370
391
|
- spec/dummy/app/controllers/application_controller.rb
|
371
392
|
- spec/dummy/app/graphql/dummy_schema.rb
|
372
393
|
- spec/dummy/app/graphql/interpreter_schema.rb
|
394
|
+
- spec/dummy/app/graphql/mutations/base_mutation.rb
|
373
395
|
- spec/dummy/app/graphql/mutations/login.rb
|
374
396
|
- spec/dummy/app/graphql/mutations/register.rb
|
375
397
|
- spec/dummy/app/graphql/mutations/register_confirmed_user.rb
|
376
398
|
- spec/dummy/app/graphql/mutations/reset_admin_password_with_token.rb
|
377
|
-
- spec/dummy/app/graphql/mutations/sign_up.rb
|
378
399
|
- spec/dummy/app/graphql/mutations/update_user.rb
|
379
|
-
- spec/dummy/app/graphql/resolvers/confirm_admin_account.rb
|
380
400
|
- spec/dummy/app/graphql/resolvers/public_user.rb
|
381
401
|
- spec/dummy/app/graphql/resolvers/user_show.rb
|
382
402
|
- spec/dummy/app/graphql/types/admin_type.rb
|
@@ -453,15 +473,9 @@ files:
|
|
453
473
|
- spec/requests/mutations/login_spec.rb
|
454
474
|
- spec/requests/mutations/logout_spec.rb
|
455
475
|
- spec/requests/mutations/register_spec.rb
|
456
|
-
- spec/requests/mutations/resend_confirmation_spec.rb
|
457
476
|
- spec/requests/mutations/resend_confirmation_with_token_spec.rb
|
458
|
-
- spec/requests/mutations/send_password_reset_spec.rb
|
459
477
|
- spec/requests/mutations/send_password_reset_with_token_spec.rb
|
460
|
-
- spec/requests/mutations/sign_up_spec.rb
|
461
|
-
- spec/requests/mutations/update_password_spec.rb
|
462
478
|
- spec/requests/mutations/update_password_with_token_spec.rb
|
463
|
-
- spec/requests/queries/check_password_token_spec.rb
|
464
|
-
- spec/requests/queries/confirm_account_spec.rb
|
465
479
|
- spec/requests/queries/introspection_query_spec.rb
|
466
480
|
- spec/requests/user_controller_spec.rb
|
467
481
|
- spec/services/mount_method/operation_preparer_spec.rb
|
@@ -505,14 +519,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
505
519
|
requirements:
|
506
520
|
- - ">="
|
507
521
|
- !ruby/object:Gem::Version
|
508
|
-
version: 2.
|
522
|
+
version: 2.4.4
|
509
523
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
510
524
|
requirements:
|
511
525
|
- - ">="
|
512
526
|
- !ruby/object:Gem::Version
|
513
527
|
version: '0'
|
514
528
|
requirements: []
|
515
|
-
rubygems_version: 3.
|
529
|
+
rubygems_version: 3.3.19
|
516
530
|
signing_key:
|
517
531
|
specification_version: 4
|
518
532
|
summary: GraphQL queries and mutations on top of devise_token_auth
|
@@ -524,13 +538,12 @@ test_files:
|
|
524
538
|
- spec/dummy/app/controllers/application_controller.rb
|
525
539
|
- spec/dummy/app/graphql/dummy_schema.rb
|
526
540
|
- spec/dummy/app/graphql/interpreter_schema.rb
|
541
|
+
- spec/dummy/app/graphql/mutations/base_mutation.rb
|
527
542
|
- spec/dummy/app/graphql/mutations/login.rb
|
528
543
|
- spec/dummy/app/graphql/mutations/register.rb
|
529
544
|
- spec/dummy/app/graphql/mutations/register_confirmed_user.rb
|
530
545
|
- spec/dummy/app/graphql/mutations/reset_admin_password_with_token.rb
|
531
|
-
- spec/dummy/app/graphql/mutations/sign_up.rb
|
532
546
|
- spec/dummy/app/graphql/mutations/update_user.rb
|
533
|
-
- spec/dummy/app/graphql/resolvers/confirm_admin_account.rb
|
534
547
|
- spec/dummy/app/graphql/resolvers/public_user.rb
|
535
548
|
- spec/dummy/app/graphql/resolvers/user_show.rb
|
536
549
|
- spec/dummy/app/graphql/types/admin_type.rb
|
@@ -607,15 +620,9 @@ test_files:
|
|
607
620
|
- spec/requests/mutations/login_spec.rb
|
608
621
|
- spec/requests/mutations/logout_spec.rb
|
609
622
|
- spec/requests/mutations/register_spec.rb
|
610
|
-
- spec/requests/mutations/resend_confirmation_spec.rb
|
611
623
|
- spec/requests/mutations/resend_confirmation_with_token_spec.rb
|
612
|
-
- spec/requests/mutations/send_password_reset_spec.rb
|
613
624
|
- spec/requests/mutations/send_password_reset_with_token_spec.rb
|
614
|
-
- spec/requests/mutations/sign_up_spec.rb
|
615
|
-
- spec/requests/mutations/update_password_spec.rb
|
616
625
|
- spec/requests/mutations/update_password_with_token_spec.rb
|
617
|
-
- spec/requests/queries/check_password_token_spec.rb
|
618
|
-
- spec/requests/queries/confirm_account_spec.rb
|
619
626
|
- spec/requests/queries/introspection_query_spec.rb
|
620
627
|
- spec/requests/user_controller_spec.rb
|
621
628
|
- spec/services/mount_method/operation_preparer_spec.rb
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Concerns
|
5
|
-
module AdditionalControllerMethods
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
attr_accessor :client_id, :token, :resource
|
10
|
-
end
|
11
|
-
|
12
|
-
def gql_devise_context(*models)
|
13
|
-
{
|
14
|
-
current_resource: authenticate_model(*models),
|
15
|
-
controller: self
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def authenticate_model(*models)
|
20
|
-
models.each do |model|
|
21
|
-
set_resource_by_token(model)
|
22
|
-
return @resource if @resource.present?
|
23
|
-
end
|
24
|
-
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def resource_class(resource = nil)
|
29
|
-
# Return the resource class instead of looking for a Devise mapping if resource is already a resource class
|
30
|
-
return resource if resource.respond_to?(:find_by)
|
31
|
-
|
32
|
-
super
|
33
|
-
end
|
34
|
-
|
35
|
-
def full_url_without_params
|
36
|
-
request.base_url + request.path
|
37
|
-
end
|
38
|
-
|
39
|
-
def set_resource_by_token(resource)
|
40
|
-
set_user_by_token(resource)
|
41
|
-
end
|
42
|
-
|
43
|
-
def graphql_context(resource_name)
|
44
|
-
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
45
|
-
`graphql_context` is deprecated and will be removed in a future version of this gem.
|
46
|
-
Use `gql_devise_context(model)` instead.
|
47
|
-
|
48
|
-
EXAMPLE
|
49
|
-
include GraphqlDevise::SetUserByToken
|
50
|
-
|
51
|
-
DummySchema.execute(params[:query], context: gql_devise_context(User))
|
52
|
-
DummySchema.execute(params[:query], context: gql_devise_context(User, Admin))
|
53
|
-
DEPRECATION
|
54
|
-
|
55
|
-
{
|
56
|
-
resource_name: resource_name,
|
57
|
-
controller: self
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def build_redirect_headers(access_token, client, redirect_header_options = {})
|
62
|
-
{
|
63
|
-
DeviseTokenAuth.headers_names[:"access-token"] => access_token,
|
64
|
-
DeviseTokenAuth.headers_names[:client] => client,
|
65
|
-
:config => params[:config],
|
66
|
-
:client_id => client,
|
67
|
-
:token => access_token
|
68
|
-
}.merge(redirect_header_options)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Concerns
|
5
|
-
module SetUserByToken
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
include DeviseTokenAuth::Concerns::SetUserByToken
|
10
|
-
include GraphqlDevise::Concerns::AdditionalControllerMethods
|
11
|
-
|
12
|
-
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
13
|
-
Including GraphqlDevise::Concerns::SetUserByToken is deprecated and will be removed in a future version of
|
14
|
-
this gem. Please use GraphqlDevise::SetUserByToken instead.
|
15
|
-
EXAMPLE
|
16
|
-
include GraphqlDevise::SetUserByToken
|
17
|
-
DEPRECATION
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module MailerHelper
|
5
|
-
def confirmation_query(resource_name:, token:, redirect_url:)
|
6
|
-
name = "#{GraphqlDevise.to_mapping_name(resource_name).camelize(:lower)}ConfirmAccount"
|
7
|
-
raw = <<-GRAPHQL
|
8
|
-
query($token:String!,$redirectUrl:String!){
|
9
|
-
#{name}(confirmationToken:$token,redirectUrl:$redirectUrl){
|
10
|
-
email
|
11
|
-
}
|
12
|
-
}
|
13
|
-
GRAPHQL
|
14
|
-
|
15
|
-
{
|
16
|
-
query: raw.delete("\n").delete(' ').html_safe,
|
17
|
-
variables: { token: token, redirectUrl: redirect_url }
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def password_reset_query(token:, redirect_url:, resource_name:)
|
22
|
-
name = "#{GraphqlDevise.to_mapping_name(resource_name).camelize(:lower)}CheckPasswordToken"
|
23
|
-
raw = <<-GRAPHQL
|
24
|
-
query($token:String!,$redirectUrl:String!){
|
25
|
-
#{name}(resetPasswordToken:$token,redirectUrl:$redirectUrl){
|
26
|
-
email
|
27
|
-
}
|
28
|
-
}
|
29
|
-
GRAPHQL
|
30
|
-
|
31
|
-
{
|
32
|
-
query: raw.delete("\n").delete(' ').html_safe,
|
33
|
-
variables: { token: token, redirectUrl: redirect_url }
|
34
|
-
}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'graphql_devise/model/with_email_updater'
|
4
|
-
|
5
|
-
module GraphqlDevise
|
6
|
-
module Concerns
|
7
|
-
module AdditionalModelMethods
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
class_methods do
|
11
|
-
def reconfirmable
|
12
|
-
devise_modules.include?(:confirmable) && column_names.include?('unconfirmed_email')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def update_with_email(attributes = {})
|
17
|
-
GraphqlDevise::Model::WithEmailUpdater.new(self, attributes).call
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'graphql_devise/model/with_email_updater'
|
4
|
-
|
5
|
-
module GraphqlDevise
|
6
|
-
module Concerns
|
7
|
-
module Model
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
include DeviseTokenAuth::Concerns::User
|
12
|
-
include GraphqlDevise::Concerns::AdditionalModelMethods
|
13
|
-
|
14
|
-
GraphqlDevise.configure_warden_serializer_for_model(self)
|
15
|
-
|
16
|
-
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
17
|
-
Including GraphqlDevise::Concerns::Model is deprecated and will be removed in a future version of
|
18
|
-
this gem. Please use GraphqlDevise::Authenticatable instead.
|
19
|
-
EXAMPLE
|
20
|
-
include GraphqlDevise::Authenticatable
|
21
|
-
DEPRECATION
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'graphql_devise/mutations/base'
|
4
|
-
require 'graphql_devise/mutations/login'
|
5
|
-
require 'graphql_devise/mutations/logout'
|
6
|
-
require 'graphql_devise/mutations/resend_confirmation'
|
7
|
-
require 'graphql_devise/mutations/resend_confirmation_with_token'
|
8
|
-
require 'graphql_devise/mutations/send_password_reset'
|
9
|
-
require 'graphql_devise/mutations/send_password_reset_with_token'
|
10
|
-
require 'graphql_devise/mutations/sign_up'
|
11
|
-
require 'graphql_devise/mutations/register'
|
12
|
-
require 'graphql_devise/mutations/update_password'
|
13
|
-
require 'graphql_devise/mutations/update_password_with_token'
|
14
|
-
require 'graphql_devise/mutations/confirm_registration_with_token'
|
15
|
-
|
16
|
-
module GraphqlDevise
|
17
|
-
module DefaultOperations
|
18
|
-
MUTATIONS = {
|
19
|
-
login: { klass: GraphqlDevise::Mutations::Login, authenticatable: true },
|
20
|
-
logout: { klass: GraphqlDevise::Mutations::Logout, authenticatable: true },
|
21
|
-
sign_up: { klass: GraphqlDevise::Mutations::SignUp, authenticatable: true, deprecation_reason: 'use register instead' },
|
22
|
-
register: { klass: GraphqlDevise::Mutations::Register, authenticatable: true },
|
23
|
-
update_password: { klass: GraphqlDevise::Mutations::UpdatePassword, authenticatable: true, deprecation_reason: 'use update_password_with_token instead' },
|
24
|
-
update_password_with_token: { klass: GraphqlDevise::Mutations::UpdatePasswordWithToken, authenticatable: true },
|
25
|
-
send_password_reset: { klass: GraphqlDevise::Mutations::SendPasswordReset, authenticatable: false, deprecation_reason: 'use send_password_reset_with_token instead' },
|
26
|
-
send_password_reset_with_token: { klass: GraphqlDevise::Mutations::SendPasswordResetWithToken, authenticatable: false },
|
27
|
-
resend_confirmation: { klass: GraphqlDevise::Mutations::ResendConfirmation, authenticatable: false, deprecation_reason: 'use resend_confirmation_with_token instead' },
|
28
|
-
resend_confirmation_with_token: { klass: GraphqlDevise::Mutations::ResendConfirmationWithToken, authenticatable: false },
|
29
|
-
confirm_registration_with_token: { klass: GraphqlDevise::Mutations::ConfirmRegistrationWithToken, authenticatable: true }
|
30
|
-
}.freeze
|
31
|
-
end
|
32
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'graphql_devise/resolvers/base'
|
4
|
-
require 'graphql_devise/resolvers/check_password_token'
|
5
|
-
require 'graphql_devise/resolvers/confirm_account'
|
6
|
-
|
7
|
-
module GraphqlDevise
|
8
|
-
module DefaultOperations
|
9
|
-
QUERIES = {
|
10
|
-
confirm_account: { klass: GraphqlDevise::Resolvers::ConfirmAccount, deprecation_reason: 'use the new confirmation flow as it does not require this query anymore' },
|
11
|
-
check_password_token: { klass: GraphqlDevise::Resolvers::CheckPasswordToken, deprecation_reason: 'use the new password reset flow as it does not require this query anymore' }
|
12
|
-
}.freeze
|
13
|
-
end
|
14
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Mutations
|
5
|
-
class ResendConfirmation < Base
|
6
|
-
argument :email, String, required: true, prepare: ->(email, _) { email.downcase }
|
7
|
-
argument :redirect_url, String, required: true
|
8
|
-
|
9
|
-
field :message, String, null: false
|
10
|
-
|
11
|
-
def resolve(email:, redirect_url:)
|
12
|
-
check_redirect_url_whitelist!(redirect_url)
|
13
|
-
|
14
|
-
resource = find_confirmable_resource(email)
|
15
|
-
|
16
|
-
if resource
|
17
|
-
yield resource if block_given?
|
18
|
-
|
19
|
-
if resource.confirmed? && !resource.pending_reconfirmation?
|
20
|
-
raise_user_error(I18n.t('graphql_devise.confirmations.already_confirmed'))
|
21
|
-
end
|
22
|
-
|
23
|
-
resource.send_confirmation_instructions(
|
24
|
-
redirect_url: redirect_url,
|
25
|
-
template_path: ['graphql_devise/mailer'],
|
26
|
-
schema_url: controller.full_url_without_params
|
27
|
-
)
|
28
|
-
|
29
|
-
{ message: I18n.t('graphql_devise.confirmations.send_instructions', email: email) }
|
30
|
-
else
|
31
|
-
raise_user_error(I18n.t('graphql_devise.confirmations.user_not_found', email: email))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def find_confirmable_resource(email)
|
38
|
-
email_insensitive = get_case_insensitive_field(:email, email)
|
39
|
-
resource = find_resource(:unconfirmed_email, email_insensitive) if resource_class.reconfirmable
|
40
|
-
resource ||= find_resource(:email, email_insensitive)
|
41
|
-
resource
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Mutations
|
5
|
-
class SendPasswordReset < Base
|
6
|
-
argument :email, String, required: true
|
7
|
-
argument :redirect_url, String, required: true
|
8
|
-
|
9
|
-
field :message, String, null: false
|
10
|
-
|
11
|
-
def resolve(email:, redirect_url:)
|
12
|
-
check_redirect_url_whitelist!(redirect_url)
|
13
|
-
|
14
|
-
resource = find_resource(:email, get_case_insensitive_field(:email, email))
|
15
|
-
|
16
|
-
if resource
|
17
|
-
yield resource if block_given?
|
18
|
-
|
19
|
-
resource.send_reset_password_instructions(
|
20
|
-
email: email,
|
21
|
-
provider: 'email',
|
22
|
-
redirect_url: redirect_url,
|
23
|
-
template_path: ['graphql_devise/mailer'],
|
24
|
-
schema_url: controller.full_url_without_params
|
25
|
-
)
|
26
|
-
|
27
|
-
if resource.errors.empty?
|
28
|
-
{ message: I18n.t('graphql_devise.passwords.send_instructions') }
|
29
|
-
else
|
30
|
-
raise_user_error_list(I18n.t('graphql_devise.invalid_resource'), errors: resource.errors.full_messages)
|
31
|
-
end
|
32
|
-
else
|
33
|
-
raise_user_error(I18n.t('graphql_devise.user_not_found'))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Mutations
|
5
|
-
class SignUp < Base
|
6
|
-
argument :email, String, required: true
|
7
|
-
argument :password, String, required: true
|
8
|
-
argument :password_confirmation, String, required: true
|
9
|
-
argument :confirm_success_url, String, required: false
|
10
|
-
|
11
|
-
field :credentials,
|
12
|
-
GraphqlDevise::Types::CredentialType,
|
13
|
-
null: true,
|
14
|
-
description: 'Authentication credentials. Null if after signUp resource is not active for authentication (e.g. Email confirmation required).'
|
15
|
-
|
16
|
-
def resolve(confirm_success_url: nil, **attrs)
|
17
|
-
resource = build_resource(attrs.merge(provider: provider))
|
18
|
-
raise_user_error(I18n.t('graphql_devise.resource_build_failed')) if resource.blank?
|
19
|
-
|
20
|
-
redirect_url = confirm_success_url || DeviseTokenAuth.default_confirm_success_url
|
21
|
-
if confirmable_enabled? && redirect_url.blank?
|
22
|
-
raise_user_error(I18n.t('graphql_devise.registrations.missing_confirm_redirect_url'))
|
23
|
-
end
|
24
|
-
|
25
|
-
check_redirect_url_whitelist!(redirect_url)
|
26
|
-
|
27
|
-
resource.skip_confirmation_notification! if resource.respond_to?(:skip_confirmation_notification!)
|
28
|
-
|
29
|
-
if resource.save
|
30
|
-
yield resource if block_given?
|
31
|
-
|
32
|
-
unless resource.confirmed?
|
33
|
-
resource.send_confirmation_instructions(
|
34
|
-
redirect_url: redirect_url,
|
35
|
-
template_path: ['graphql_devise/mailer'],
|
36
|
-
schema_url: controller.full_url_without_params
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
response_payload = { authenticatable: resource }
|
41
|
-
|
42
|
-
response_payload[:credentials] = set_auth_headers(resource) if resource.active_for_authentication?
|
43
|
-
|
44
|
-
response_payload
|
45
|
-
else
|
46
|
-
resource.try(:clean_up_passwords)
|
47
|
-
raise_user_error_list(
|
48
|
-
I18n.t('graphql_devise.registration_failed'),
|
49
|
-
errors: resource.errors.full_messages
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def build_resource(attrs)
|
57
|
-
resource_class.new(attrs)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphqlDevise
|
4
|
-
module Mutations
|
5
|
-
class UpdatePassword < Base
|
6
|
-
argument :password, String, required: true
|
7
|
-
argument :password_confirmation, String, required: true
|
8
|
-
argument :current_password, String, required: false
|
9
|
-
|
10
|
-
def resolve(current_password: nil, **attrs)
|
11
|
-
if current_resource.blank?
|
12
|
-
raise_user_error(I18n.t('graphql_devise.not_authenticated'))
|
13
|
-
elsif current_resource.provider != 'email'
|
14
|
-
raise_user_error(
|
15
|
-
I18n.t('graphql_devise.passwords.password_not_required', provider: current_resource.provider.humanize)
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
if update_resource_password(current_password, attrs)
|
20
|
-
current_resource.allow_password_change = false if recoverable_enabled?
|
21
|
-
current_resource.save!
|
22
|
-
|
23
|
-
yield current_resource if block_given?
|
24
|
-
|
25
|
-
{ authenticatable: current_resource }
|
26
|
-
else
|
27
|
-
raise_user_error_list(
|
28
|
-
I18n.t('graphql_devise.passwords.update_password_error'),
|
29
|
-
errors: current_resource.errors.full_messages
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def update_resource_password(current_password, attrs)
|
37
|
-
allow_password_change = recoverable_enabled? && current_resource.allow_password_change == true
|
38
|
-
if DeviseTokenAuth.check_current_password_before_update == false || allow_password_change
|
39
|
-
current_resource.public_send(:update, attrs)
|
40
|
-
else
|
41
|
-
current_resource.public_send(:update_with_password, attrs.merge(current_password: current_password))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|