graphql_devise 0.13.2 → 0.13.3
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/CHANGELOG.md +8 -0
- data/app/models/graphql_devise/concerns/model.rb +6 -0
- data/lib/graphql_devise/version.rb +1 -1
- data/spec/dummy/app/graphql/resolvers/confirm_admin_account.rb +13 -0
- data/spec/dummy/app/graphql/types/admin_type.rb +8 -0
- data/spec/dummy/config/initializers/devise.rb +1 -1
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/schema.rb +0 -2
- data/spec/requests/queries/confirm_account_spec.rb +100 -42
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f53fa7a8d2d7b2358f448a3debe5bc56eba25282e51006e88922340eaedc3ac
|
4
|
+
data.tar.gz: '07183950cd6bd45e2228cbe20fd41ed8d8352e8191aa51f39d1a07e8ce04310c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75da3fcc2f769c67f3c07ec7e732cb1ca82a1909ebb2cb35b03b4a902f7367eb17319398c7daf848598a71288c29aad84720f418174d1fb7a9fefbe7a6a75399
|
7
|
+
data.tar.gz: da0bc0fdf1a5f3cefd4b76e7c08872a893606881ca51c3727c9051db753d938a57abdc25f6b1afb5171f0ec7a5df8104cae8ff14e5bc20bc48b050e15e2911bc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.13.3](https://github.com/graphql-devise/graphql_devise/tree/v0.13.3) (2020-08-13)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.13.2...v0.13.3)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Fix unconfirmed\_email confirmation. Ignore devise reconfirmable config. [\#126](https://github.com/graphql-devise/graphql_devise/pull/126) ([mcelicalderon](https://github.com/mcelicalderon))
|
10
|
+
|
3
11
|
## [v0.13.2](https://github.com/graphql-devise/graphql_devise/tree/v0.13.2) (2020-08-12)
|
4
12
|
|
5
13
|
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.13.1...v0.13.2)
|
@@ -10,6 +10,12 @@ module GraphqlDevise
|
|
10
10
|
def update_with_email(attributes = {})
|
11
11
|
GraphqlDevise::Model::WithEmailUpdater.new(self, attributes).call
|
12
12
|
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def pending_reconfirmation?
|
17
|
+
devise_modules.include?(:confirmable) && try(:unconfirmed_email).present?
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Resolvers
|
4
|
+
class ConfirmAdminAccount < GraphqlDevise::Resolvers::ConfirmAccount
|
5
|
+
type Types::AdminType, null: false
|
6
|
+
|
7
|
+
def resolve(confirmation_token:, redirect_url:)
|
8
|
+
super do |admin|
|
9
|
+
controller.sign_in(admin)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -142,7 +142,7 @@ Devise.setup do |config|
|
|
142
142
|
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
143
143
|
# db field (see migrations). Until confirmed, new email is stored in
|
144
144
|
# unconfirmed_email column, and copied to email column on successful confirmation.
|
145
|
-
config.reconfirmable =
|
145
|
+
config.reconfirmable = false
|
146
146
|
|
147
147
|
# Defines which key will be used when confirming an account
|
148
148
|
# config.confirmation_keys = [:email]
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
# This file is auto-generated from the current state of the database. Instead
|
4
2
|
# of editing this file, please use the migrations feature of Active Record to
|
5
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -5,60 +5,118 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe 'Account confirmation' do
|
6
6
|
include_context 'with graphql query request'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
context 'when using the user model' do
|
9
|
+
let(:user) { create(:user, confirmed_at: nil) }
|
10
|
+
let(:redirect) { Faker::Internet.url }
|
11
|
+
let(:query) do
|
12
|
+
<<-GRAPHQL
|
13
|
+
{
|
14
|
+
userConfirmAccount(
|
15
|
+
confirmationToken: "#{token}"
|
16
|
+
redirectUrl: "#{redirect}"
|
17
|
+
) {
|
18
|
+
email
|
19
|
+
name
|
20
|
+
}
|
19
21
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
GRAPHQL
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when confirmation token is correct' do
|
26
|
+
let(:token) { user.confirmation_token }
|
27
|
+
|
28
|
+
before do
|
29
|
+
user.send_confirmation_instructions(
|
30
|
+
template_path: ['graphql_devise/mailer'],
|
31
|
+
controller: 'graphql_devise/graphql',
|
32
|
+
schema_url: 'http://not-using-this-value.com/gql'
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'confirms the resource and redirects to the sent url' do
|
37
|
+
expect do
|
38
|
+
get_request
|
39
|
+
user.reload
|
40
|
+
end.to(change(user, :confirmed_at).from(nil))
|
41
|
+
|
42
|
+
expect(response).to redirect_to("#{redirect}?account_confirmation_success=true")
|
43
|
+
expect(user).to be_active_for_authentication
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when unconfirmed_email is present' do
|
47
|
+
let(:user) { create(:user, :confirmed, unconfirmed_email: 'vvega@wallaceinc.com') }
|
23
48
|
|
24
|
-
|
25
|
-
|
49
|
+
it 'confirms the unconfirmed email and redirects' do
|
50
|
+
expect do
|
51
|
+
get_request
|
52
|
+
user.reload
|
53
|
+
end.to change(user, :email).from(user.email).to('vvega@wallaceinc.com').and(
|
54
|
+
change(user, :unconfirmed_email).from('vvega@wallaceinc.com').to(nil)
|
55
|
+
)
|
26
56
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
controller: 'graphql_devise/graphql',
|
31
|
-
schema_url: 'http://not-using-this-value.com/gql'
|
32
|
-
)
|
57
|
+
expect(response).to redirect_to("#{redirect}?account_confirmation_success=true")
|
58
|
+
end
|
59
|
+
end
|
33
60
|
end
|
34
61
|
|
35
|
-
|
36
|
-
|
37
|
-
get_request
|
38
|
-
user.reload
|
39
|
-
end.to(change(user, :confirmed_at).from(nil))
|
62
|
+
context 'when reset password token is not found' do
|
63
|
+
let(:token) { "#{user.confirmation_token}-invalid" }
|
40
64
|
|
41
|
-
|
42
|
-
|
65
|
+
it 'does *NOT* confirm the user nor does the redirection' do
|
66
|
+
expect do
|
67
|
+
get_request
|
68
|
+
user.reload
|
69
|
+
end.not_to(change(user, :confirmed_at).from(nil))
|
70
|
+
|
71
|
+
expect(response).not_to be_redirect
|
72
|
+
expect(json_response[:errors]).to contain_exactly(
|
73
|
+
hash_including(
|
74
|
+
message: 'Invalid confirmation token. Please try again',
|
75
|
+
extensions: { code: 'USER_ERROR' }
|
76
|
+
)
|
77
|
+
)
|
78
|
+
end
|
43
79
|
end
|
44
80
|
end
|
45
81
|
|
46
|
-
context 'when
|
47
|
-
let(:
|
82
|
+
context 'when using the admin model' do
|
83
|
+
let(:admin) { create(:admin, confirmed_at: nil) }
|
84
|
+
let(:redirect) { Faker::Internet.url }
|
85
|
+
let(:query) do
|
86
|
+
<<-GRAPHQL
|
87
|
+
{
|
88
|
+
adminConfirmAccount(
|
89
|
+
confirmationToken: "#{token}"
|
90
|
+
redirectUrl: "#{redirect}"
|
91
|
+
) {
|
92
|
+
email
|
93
|
+
}
|
94
|
+
}
|
95
|
+
GRAPHQL
|
96
|
+
end
|
48
97
|
|
49
|
-
|
50
|
-
|
51
|
-
get_request
|
52
|
-
user.reload
|
53
|
-
end.not_to(change(user, :confirmed_at).from(nil))
|
98
|
+
context 'when confirmation token is correct' do
|
99
|
+
let(:token) { admin.confirmation_token }
|
54
100
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
101
|
+
before do
|
102
|
+
admin.send_confirmation_instructions(
|
103
|
+
template_path: ['graphql_devise/mailer'],
|
104
|
+
controller: 'graphql_devise/graphql',
|
105
|
+
schema_url: 'http://not-using-this-value.com/gql'
|
60
106
|
)
|
61
|
-
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'confirms the resource, persists credentials on the DB and redirects to the sent url' do
|
110
|
+
expect do
|
111
|
+
get_request
|
112
|
+
admin.reload
|
113
|
+
end.to change(admin, :confirmed_at).from(nil).and(
|
114
|
+
change { admin.tokens.keys.count }.from(0).to(1)
|
115
|
+
)
|
116
|
+
|
117
|
+
expect(response).to redirect_to(/\A#{redirect}.+access\-token=/)
|
118
|
+
expect(admin).to be_active_for_authentication
|
119
|
+
end
|
62
120
|
end
|
63
121
|
end
|
64
122
|
end
|
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.13.
|
4
|
+
version: 0.13.3
|
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: 2020-08-
|
12
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise_token_auth
|
@@ -364,8 +364,10 @@ files:
|
|
364
364
|
- spec/dummy/app/graphql/mutations/register_confirmed_user.rb
|
365
365
|
- spec/dummy/app/graphql/mutations/sign_up.rb
|
366
366
|
- spec/dummy/app/graphql/mutations/update_user.rb
|
367
|
+
- spec/dummy/app/graphql/resolvers/confirm_admin_account.rb
|
367
368
|
- spec/dummy/app/graphql/resolvers/public_user.rb
|
368
369
|
- spec/dummy/app/graphql/resolvers/user_show.rb
|
370
|
+
- spec/dummy/app/graphql/types/admin_type.rb
|
369
371
|
- spec/dummy/app/graphql/types/base_object.rb
|
370
372
|
- spec/dummy/app/graphql/types/custom_admin_type.rb
|
371
373
|
- spec/dummy/app/graphql/types/mutation_type.rb
|
@@ -505,8 +507,10 @@ test_files:
|
|
505
507
|
- spec/dummy/app/graphql/mutations/register_confirmed_user.rb
|
506
508
|
- spec/dummy/app/graphql/mutations/sign_up.rb
|
507
509
|
- spec/dummy/app/graphql/mutations/update_user.rb
|
510
|
+
- spec/dummy/app/graphql/resolvers/confirm_admin_account.rb
|
508
511
|
- spec/dummy/app/graphql/resolvers/public_user.rb
|
509
512
|
- spec/dummy/app/graphql/resolvers/user_show.rb
|
513
|
+
- spec/dummy/app/graphql/types/admin_type.rb
|
510
514
|
- spec/dummy/app/graphql/types/base_object.rb
|
511
515
|
- spec/dummy/app/graphql/types/custom_admin_type.rb
|
512
516
|
- spec/dummy/app/graphql/types/mutation_type.rb
|