graphql_devise 0.7.0 → 0.8.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/CHANGELOG.md +8 -0
- data/README.md +4 -4
- data/app/graphql/graphql_devise/mutations/login.rb +1 -1
- data/app/graphql/graphql_devise/mutations/logout.rb +1 -1
- data/app/graphql/graphql_devise/mutations/resend_confirmation.rb +1 -1
- data/app/graphql/graphql_devise/mutations/send_password_reset.rb +1 -1
- data/app/graphql/graphql_devise/mutations/sign_up.rb +1 -1
- data/app/graphql/graphql_devise/mutations/update_password.rb +1 -1
- data/app/graphql/graphql_devise/resolvers/confirm_account.rb +1 -1
- data/app/graphql/graphql_devise/types/{authenticable_type.rb → authenticatable_type.rb} +1 -1
- data/lib/graphql_devise/rails/routes.rb +5 -5
- data/lib/graphql_devise/version.rb +1 -1
- data/spec/dummy/app/graphql/mutations/login.rb +1 -1
- data/spec/dummy/app/graphql/mutations/sign_up.rb +1 -1
- data/spec/dummy/config/routes.rb +3 -3
- data/spec/requests/mutations/login_spec.rb +4 -4
- data/spec/requests/mutations/logout_spec.rb +4 -4
- data/spec/requests/mutations/resend_confirmation_spec.rb +2 -2
- data/spec/requests/mutations/send_password_reset_spec.rb +1 -1
- data/spec/requests/mutations/sign_up_spec.rb +2 -2
- data/spec/requests/mutations/update_password_spec.rb +2 -2
- data/spec/requests/queries/check_password_token_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b6f3ff9d48c3f0aead4020e78b67b67d4a4f006d0567e46c9d25e2d4ec75027
|
4
|
+
data.tar.gz: c8b9e08819e1b67ee96728190a3a99063ad6370fb2764c14f5d7ab170ee8dbbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1492eb845e6ad50959eee321dbd0feb7efa2ebd8ff37784080715305e2d072109dd0575e2ecbb7ac584f868156a7c4d646101edc4962bc88a86d0005acbfc085
|
7
|
+
data.tar.gz: 811254816bf9d2ca63d9064339c0d85bf7073ec7266953f2b8caa42e0be3924277a4a483c05bd7ff60326aeb284fb3632bd53fad2cf2912481c16d3d5d550368
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.8.0](https://github.com/graphql-devise/graphql_devise/tree/v0.8.0) (2019-11-26)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.7.0...v0.8.0)
|
6
|
+
|
7
|
+
**Breaking changes:**
|
8
|
+
|
9
|
+
- Set standard to use authenticatable per Devise's coding standard. [\#46](https://github.com/graphql-devise/graphql_devise/pull/46) ([aarona](https://github.com/aarona))
|
10
|
+
|
3
11
|
## [v0.7.0](https://github.com/graphql-devise/graphql_devise/tree/v0.7.0) (2019-11-25)
|
4
12
|
|
5
13
|
[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.6.0...v0.7.0)
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ Rails.application.routes.draw do
|
|
61
61
|
mount_graphql_devise_for(
|
62
62
|
'User',
|
63
63
|
at: 'api/v1',
|
64
|
-
|
64
|
+
authenticatable_type: Types::MyCustomUserType,
|
65
65
|
operations: {
|
66
66
|
login: Mutations::Login
|
67
67
|
},
|
@@ -81,8 +81,8 @@ and [queries](https://github.com/graphql-devise/graphql_devise/blob/b5985036e01e
|
|
81
81
|
All mutations and queries are built so you can extend default behavior just by extending
|
82
82
|
our default classes and yielding your customized code after calling `super`, example
|
83
83
|
[here](https://github.com/graphql-devise/graphql_devise/blob/b5985036e01ea064e43e457b4f0c8516f172471c/spec/dummy/app/graphql/mutations/login.rb#L6).
|
84
|
-
1. `
|
85
|
-
and an `
|
84
|
+
1. `authenticatable_type`: By default, the gem will add an `authenticatable` field to every mutation
|
85
|
+
and an `authenticatable` type to every query. Gem will try to use `Types::<model>Type` by
|
86
86
|
default, so in our example you could define `Types::UserType` and every query and mutation
|
87
87
|
will use it. But, you can override this type with this option like in the example.
|
88
88
|
1. `skip`: An array of the operations that should not be available in the authentication schema. All these operations are
|
@@ -170,7 +170,7 @@ Here is a list of the available mutations and queries assuming your mounted mode
|
|
170
170
|
1. `userSendResetPassword(email: String!, redirectUrl: String!): UserSendReserPasswordPayload`
|
171
171
|
1. `userResendConfirmation(email: String!, redirectUrl: String!): UserResendConfirmationPayload`
|
172
172
|
|
173
|
-
The `UserResendConfirmationPayload` will return the `
|
173
|
+
The `UserResendConfirmationPayload` will return the `authenticatable` resource that was sent the confirmation instructions but also has a `message: String!` that can be used to notify a user what to do after the instructions were sent to them
|
174
174
|
|
175
175
|
#### Queries
|
176
176
|
1. `userConfirmAccount(confirmationToken: String!, redirectUrl: String!): User`
|
@@ -17,7 +17,7 @@ module GraphqlDevise
|
|
17
17
|
|
18
18
|
yield resource if block_given?
|
19
19
|
|
20
|
-
{
|
20
|
+
{ authenticatable: resource}
|
21
21
|
elsif resource && !active_for_authentication?(resource)
|
22
22
|
if locked?(resource)
|
23
23
|
raise_user_error(I18n.t('graphql_devise.mailer.unlock_instructions.account_lock_msg'))
|
@@ -39,9 +39,9 @@ module ActionDispatch::Routing
|
|
39
39
|
skip: [:sessions, :registrations, :passwords, :confirmations, :omniauth_callbacks, :unlocks]
|
40
40
|
)
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
authenticatable_type = opts[:authenticatable_type] ||
|
43
|
+
"Types::#{resource}Type".safe_constantize ||
|
44
|
+
GraphqlDevise::Types::AuthenticatableType
|
45
45
|
|
46
46
|
used_mutations = if only_operations.present?
|
47
47
|
default_mutations.slice(*only_operations)
|
@@ -54,7 +54,7 @@ module ActionDispatch::Routing
|
|
54
54
|
else
|
55
55
|
new_mutation = Class.new(mutation)
|
56
56
|
new_mutation.graphql_name("#{resource}#{action.to_s.camelize(:upper)}")
|
57
|
-
new_mutation.field(:
|
57
|
+
new_mutation.field(:authenticatable, authenticatable_type, null: true)
|
58
58
|
|
59
59
|
new_mutation
|
60
60
|
end
|
@@ -74,7 +74,7 @@ module ActionDispatch::Routing
|
|
74
74
|
else
|
75
75
|
new_query = Class.new(query)
|
76
76
|
new_query.graphql_name("#{resource}#{action.to_s.camelize(:upper)}")
|
77
|
-
new_query.type(
|
77
|
+
new_query.type(authenticatable_type, null: true)
|
78
78
|
|
79
79
|
new_query
|
80
80
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -6,9 +6,9 @@ Rails.application.routes.draw do
|
|
6
6
|
|
7
7
|
mount_graphql_devise_for(
|
8
8
|
'Admin',
|
9
|
-
|
10
|
-
skip:
|
11
|
-
at:
|
9
|
+
authenticatable_type: Types::CustomAdminType,
|
10
|
+
skip: [:sign_up, :check_password_token],
|
11
|
+
at: '/api/v1/admin/graphql_auth'
|
12
12
|
)
|
13
13
|
|
14
14
|
mount_graphql_devise_for(
|
@@ -100,7 +100,7 @@ RSpec.describe 'Login Requests' do
|
|
100
100
|
email: "#{admin.email}",
|
101
101
|
password: "#{password}"
|
102
102
|
) {
|
103
|
-
|
103
|
+
authenticatable { email customField }
|
104
104
|
}
|
105
105
|
}
|
106
106
|
GRAPHQL
|
@@ -110,7 +110,7 @@ RSpec.describe 'Login Requests' do
|
|
110
110
|
|
111
111
|
it 'works alongside the user mount point' do
|
112
112
|
expect(json_response[:data][:adminLogin]).to include(
|
113
|
-
|
113
|
+
authenticatable: { email: admin.email, customField: "email: #{admin.email}" }
|
114
114
|
)
|
115
115
|
end
|
116
116
|
end
|
@@ -124,7 +124,7 @@ RSpec.describe 'Login Requests' do
|
|
124
124
|
email: "#{guest.email}",
|
125
125
|
password: "#{password}"
|
126
126
|
) {
|
127
|
-
|
127
|
+
authenticatable { email }
|
128
128
|
}
|
129
129
|
}
|
130
130
|
GRAPHQL
|
@@ -134,7 +134,7 @@ RSpec.describe 'Login Requests' do
|
|
134
134
|
|
135
135
|
it 'works alongside the user mount point' do
|
136
136
|
expect(json_response[:data][:guestLogin]).to include(
|
137
|
-
|
137
|
+
authenticatable: { email: guest.email }
|
138
138
|
)
|
139
139
|
end
|
140
140
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe 'Logout Requests' do
|
|
8
8
|
<<-GRAPHQL
|
9
9
|
mutation {
|
10
10
|
userLogout {
|
11
|
-
|
11
|
+
authenticatable { email }
|
12
12
|
}
|
13
13
|
}
|
14
14
|
GRAPHQL
|
@@ -23,7 +23,7 @@ RSpec.describe 'Logout Requests' do
|
|
23
23
|
expect(response).not_to include_auth_headers
|
24
24
|
expect(user.reload.tokens.keys).to be_empty
|
25
25
|
expect(json_response[:data][:userLogout]).to match(
|
26
|
-
|
26
|
+
authenticatable: { email: user.email }
|
27
27
|
)
|
28
28
|
expect(json_response[:errors]).to be_nil
|
29
29
|
end
|
@@ -45,7 +45,7 @@ RSpec.describe 'Logout Requests' do
|
|
45
45
|
<<-GRAPHQL
|
46
46
|
mutation {
|
47
47
|
adminLogout {
|
48
|
-
|
48
|
+
authenticatable { email }
|
49
49
|
}
|
50
50
|
}
|
51
51
|
GRAPHQL
|
@@ -57,7 +57,7 @@ RSpec.describe 'Logout Requests' do
|
|
57
57
|
expect(response).not_to include_auth_headers
|
58
58
|
expect(admin.reload.tokens.keys).to be_empty
|
59
59
|
expect(json_response[:data][:adminLogout]).to match(
|
60
|
-
|
60
|
+
authenticatable: { email: admin.email }
|
61
61
|
)
|
62
62
|
expect(json_response[:errors]).to be_nil
|
63
63
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe 'Resend confirmation' do
|
|
15
15
|
redirectUrl:"#{redirect}"
|
16
16
|
) {
|
17
17
|
message
|
18
|
-
|
18
|
+
authenticatable {
|
19
19
|
id
|
20
20
|
email
|
21
21
|
}
|
@@ -28,7 +28,7 @@ RSpec.describe 'Resend confirmation' do
|
|
28
28
|
it 'sends an email to the user with confirmation url and returns a success message' do
|
29
29
|
expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
30
30
|
expect(json_response[:data][:userResendConfirmation]).to include(
|
31
|
-
|
31
|
+
authenticatable: {
|
32
32
|
id: id,
|
33
33
|
email: email
|
34
34
|
},
|
@@ -87,7 +87,7 @@ RSpec.describe 'Sign Up process' do
|
|
87
87
|
passwordConfirmation: "#{password}"
|
88
88
|
confirmSuccessUrl: "#{redirect}"
|
89
89
|
) {
|
90
|
-
|
90
|
+
authenticatable {
|
91
91
|
email
|
92
92
|
}
|
93
93
|
}
|
@@ -114,7 +114,7 @@ RSpec.describe 'Sign Up process' do
|
|
114
114
|
passwordConfirmation: "#{password}"
|
115
115
|
confirmSuccessUrl: "#{redirect}"
|
116
116
|
) {
|
117
|
-
|
117
|
+
authenticatable {
|
118
118
|
email
|
119
119
|
}
|
120
120
|
}
|
@@ -10,7 +10,7 @@ RSpec.describe 'Update Password Requests' do
|
|
10
10
|
|
11
11
|
expect(response).to include_auth_headers
|
12
12
|
expect(json_response[:data][:userUpdatePassword]).to match(
|
13
|
-
|
13
|
+
authenticatable: { email: user.email }
|
14
14
|
)
|
15
15
|
expect(json_response[:errors]).to be_nil
|
16
16
|
expect(user).to be_valid_password(password)
|
@@ -33,7 +33,7 @@ RSpec.describe 'Update Password Requests' do
|
|
33
33
|
passwordConfirmation: "#{password_confirmation}",
|
34
34
|
currentPassword: "#{current_password}"
|
35
35
|
) {
|
36
|
-
|
36
|
+
authenticatable { email }
|
37
37
|
}
|
38
38
|
}
|
39
39
|
GRAPHQL
|
@@ -26,7 +26,7 @@ RSpec.describe 'Check Password Token Requests' do
|
|
26
26
|
context 'when redirect_url is not provided' do
|
27
27
|
let(:redirect_url) { nil }
|
28
28
|
|
29
|
-
it 'returns
|
29
|
+
it 'returns authenticatable and credentials in the headers' do
|
30
30
|
get_request
|
31
31
|
|
32
32
|
expect(response).to include_auth_headers
|
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: 0.8.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: 2019-11-
|
12
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise_token_auth
|
@@ -270,7 +270,7 @@ files:
|
|
270
270
|
- app/graphql/graphql_devise/resolvers/check_password_token.rb
|
271
271
|
- app/graphql/graphql_devise/resolvers/confirm_account.rb
|
272
272
|
- app/graphql/graphql_devise/schema.rb
|
273
|
-
- app/graphql/graphql_devise/types/
|
273
|
+
- app/graphql/graphql_devise/types/authenticatable_type.rb
|
274
274
|
- app/graphql/graphql_devise/types/mutation_type.rb
|
275
275
|
- app/graphql/graphql_devise/types/query_type.rb
|
276
276
|
- app/helpers/graphql_devise/application_helper.rb
|