graphql-auth 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a5caee96621fce2d96fada271e528b513529e1f31036774ce512e832deb0fbe
4
- data.tar.gz: a9df192c6455909cf08695d852f809008aac56c3f40f98f9181fae3ba1ca9c80
3
+ metadata.gz: 7321053f154f4a124cc2b732bdb80b97faabf404bc90b9af28fc37345728db43
4
+ data.tar.gz: 666586e19bce1a314cb55cbaadf49cdc84da267f562e6844321c7c5b0b90528c
5
5
  SHA512:
6
- metadata.gz: e35e7e38363252aed17bf28a91ec98d7c1ea83cdc412c7f17106fedc2d1d56bd345a15200f5ac2b08aec03f8a241d8c661e56d7b2027352c94b39745001b503c
7
- data.tar.gz: f8fecc6295f27c8f364f3de464a8aad808f10350feb30f2bfa97b4d0388a109dd339f6b6707a2dfabea9e17c2848871a3201bb9c3b7d4d015bf8d5075647685a
6
+ metadata.gz: c5fb1f82cbb9ebc4d2141b322c297b5a30e8d8312016bb848312732fa44ab1a2d09e9f972e46b88335e0dc1d3bcc309f544b20e70983b27c66d9631fb7724ee4
7
+ data.tar.gz: 8c3818cb610f864f631f9d07a6805d9a3668001f9eb9e2b29cd23dcb14108aacd3d7ad209cc1ad1eec20413e9ee8fc91f41d18b12b75a4383fd3b6790f9e5cfd
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ ## 0.6.1
4
+
5
+ Multiple fixes to allow usage of the gem without the lockable Devise
6
+ feature
7
+
8
+ ## 0.6.0
9
+
10
+ ### Important
11
+
12
+ Upgrade to 0.6.1 if you plan on using this gem without Devise's lockable
13
+ feature
14
+
15
+ ### New features
16
+
17
+ Added to possibility to use your own sign_up and update_account mutations
18
+ to allow custom fields for your user accounts
19
+
20
+ ### Breaking changes
21
+
22
+ Configuration file was changed and some config names now have a different
23
+ use.
24
+
25
+ Please make sure to update your config file with the current version.
26
+
27
+ **Those settings were renamed for more clarity**
28
+ * sign_up_mutation => allow_sign_up
29
+ * lock_account_mutation => allow_lock_account
30
+ * unlock_account_mutation => allow_unlock_account
31
+
32
+ The updated config file should look like this:
33
+ ```
34
+ GraphQL::Auth.configure do |config|
35
+ # config.token_lifespan = 4.hours
36
+ # config.jwt_secret_key = ENV['JWT_SECRET_KEY']
37
+ # config.app_url = ENV['APP_URL']
38
+
39
+ # config.user_type = '::Types::Auth::User'
40
+
41
+ # Devise allowed actions
42
+ # Don't forget to enable the lockable setting in your Devise user model if you plan on using the lock_account feature
43
+ # config.allow_sign_up = true
44
+ # config.allow_lock_account = false
45
+ # config.allow_unlock_account = false
46
+
47
+ # Allow custom mutations for signup and update account
48
+ # config.sign_up_mutation = '::Mutations::Auth::SignUp'
49
+ # config.update_account_mutation = '::Mutations::Auth::UpdateAccount'
50
+ end
51
+ ```
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Mutations::Auth::ForgotPassword < GraphQL::Schema::Mutation
4
+ include ::Graphql::AccountLockHelper
5
+
4
6
  argument :email, String, required: true do
5
7
  description 'The email with forgotten password'
6
8
  end
@@ -10,7 +12,11 @@ class Mutations::Auth::ForgotPassword < GraphQL::Schema::Mutation
10
12
  field :valid, Boolean, null: false
11
13
 
12
14
  def resolve(email:)
13
- user = User.where(locked_at: nil).find_by email: email
15
+ if lockable?
16
+ user = User.where(locked_at: nil).find_by email: email
17
+ else
18
+ user = User.find_by email: email
19
+ end
14
20
 
15
21
  user.send_reset_password_instructions if user.present?
16
22
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Mutations::Auth::ResetPassword < GraphQL::Schema::Mutation
4
+ include ::Graphql::AccountLockHelper
5
+
4
6
  argument :reset_password_token, String, required: true do
5
7
  description "Reset password token"
6
8
  end
@@ -17,7 +19,11 @@ class Mutations::Auth::ResetPassword < GraphQL::Schema::Mutation
17
19
  field :success, Boolean, null: false
18
20
 
19
21
  def resolve(args)
20
- user = User.where(locked_at: nil).reset_password_by_token args
22
+ if lockable?
23
+ user = User.where(locked_at: nil).reset_password_by_token args
24
+ else
25
+ user = User.reset_password_by_token args
26
+ end
21
27
 
22
28
  if user.errors.any?
23
29
  {
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Mutations::Auth::SignIn < GraphQL::Schema::Mutation
4
+ include ::Graphql::AccountLockHelper
4
5
  include ::Graphql::TokenHelper
5
6
 
6
7
  argument :email, String, required: true do
@@ -22,7 +23,11 @@ class Mutations::Auth::SignIn < GraphQL::Schema::Mutation
22
23
  def resolve(email:, password:, remember_me:)
23
24
  response = context[:response]
24
25
 
25
- user = User.where(locked_at: nil).find_by email: email
26
+ if lockable?
27
+ user = User.where(locked_at: nil).find_by email: email
28
+ else
29
+ user = User.find_by email: email
30
+ end
26
31
 
27
32
  valid_sign_in = user.present? && user.valid_password?(password)
28
33
 
@@ -1,8 +1,14 @@
1
1
  module Graphql
2
2
  module AccountLockHelper
3
+
3
4
  def account_locked?(user)
4
- return false unless GraphQL::Auth.configuration.allow_lock_account
5
+ return false unless lockable?
5
6
  user.access_locked?
6
7
  end
8
+
9
+ def lockable?
10
+ GraphQL::Auth.configuration.allow_lock_account
11
+ end
12
+
7
13
  end
8
14
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Auth
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Ferland
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-15 00:00:00.000000000 Z
13
+ date: 2019-08-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.0.2
103
+ version: '2.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.0.2
110
+ version: '2.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
+ - CHANGELOG.md
160
161
  - README.md
161
162
  - Rakefile
162
163
  - app/graphql/mutations/auth/forgot_password.rb