devise_token_auth 0.2.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_token_auth might be problematic. Click here for more details.

Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/Rakefile +9 -4
  4. data/app/controllers/devise_token_auth/application_controller.rb +5 -7
  5. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +2 -2
  6. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +18 -10
  7. data/app/controllers/devise_token_auth/confirmations_controller.rb +2 -2
  8. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +17 -23
  9. data/app/controllers/devise_token_auth/passwords_controller.rb +23 -27
  10. data/app/controllers/devise_token_auth/registrations_controller.rb +17 -15
  11. data/app/controllers/devise_token_auth/sessions_controller.rb +8 -12
  12. data/app/controllers/devise_token_auth/token_validations_controller.rb +3 -3
  13. data/app/controllers/devise_token_auth/unlocks_controller.rb +10 -12
  14. data/app/models/devise_token_auth/concerns/user.rb +27 -36
  15. data/config/initializers/devise.rb +1 -1
  16. data/lib/devise_token_auth.rb +6 -6
  17. data/lib/devise_token_auth/controllers/helpers.rb +14 -4
  18. data/lib/devise_token_auth/engine.rb +11 -13
  19. data/lib/devise_token_auth/errors.rb +1 -1
  20. data/lib/devise_token_auth/rails/routes.rb +29 -29
  21. data/lib/devise_token_auth/url.rb +6 -4
  22. data/lib/devise_token_auth/version.rb +1 -1
  23. data/lib/generators/devise_token_auth/install_generator.rb +52 -39
  24. data/lib/generators/devise_token_auth/install_views_generator.rb +5 -5
  25. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +1 -1
  26. data/lib/generators/devise_token_auth/templates/{user.rb → user.rb.erb} +0 -0
  27. data/test/controllers/custom/custom_confirmations_controller_test.rb +3 -1
  28. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +2 -0
  29. data/test/controllers/custom/custom_passwords_controller_test.rb +4 -2
  30. data/test/controllers/custom/custom_registrations_controller_test.rb +6 -8
  31. data/test/controllers/custom/custom_sessions_controller_test.rb +5 -5
  32. data/test/controllers/custom/custom_token_validations_controller_test.rb +3 -3
  33. data/test/controllers/demo_group_controller_test.rb +2 -6
  34. data/test/controllers/demo_mang_controller_test.rb +2 -5
  35. data/test/controllers/demo_user_controller_test.rb +8 -17
  36. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +2 -2
  37. data/test/controllers/devise_token_auth/passwords_controller_test.rb +13 -9
  38. data/test/controllers/devise_token_auth/registrations_controller_test.rb +8 -8
  39. data/test/controllers/devise_token_auth/sessions_controller_test.rb +22 -33
  40. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +2 -6
  41. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +1 -1
  42. data/test/controllers/overrides/confirmations_controller_test.rb +3 -1
  43. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +3 -1
  44. data/test/controllers/overrides/passwords_controller_test.rb +25 -29
  45. data/test/controllers/overrides/registrations_controller_test.rb +4 -2
  46. data/test/controllers/overrides/sessions_controller_test.rb +4 -4
  47. data/test/controllers/overrides/token_validations_controller_test.rb +3 -3
  48. data/test/dummy/app/controllers/custom/confirmations_controller.rb +0 -2
  49. data/test/dummy/app/controllers/custom/passwords_controller.rb +1 -4
  50. data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -2
  51. data/test/dummy/app/controllers/custom/sessions_controller.rb +1 -3
  52. data/test/dummy/app/controllers/custom/token_validations_controller.rb +1 -3
  53. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -3
  54. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +3 -3
  55. data/test/dummy/app/controllers/overrides/passwords_controller.rb +5 -5
  56. data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
  57. data/test/dummy/app/controllers/overrides/sessions_controller.rb +8 -10
  58. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +3 -5
  59. data/test/dummy/app/helpers/application_helper.rb +1027 -1036
  60. data/test/dummy/app/models/scoped_user.rb +2 -2
  61. data/test/dummy/app/models/unregisterable_user.rb +2 -2
  62. data/test/dummy/app/models/user.rb +1 -1
  63. data/test/dummy/config.ru +5 -3
  64. data/test/dummy/config/application.rb +2 -2
  65. data/test/dummy/config/boot.rb +2 -2
  66. data/test/dummy/config/environment.rb +1 -1
  67. data/test/dummy/config/environments/development.rb +3 -3
  68. data/test/dummy/config/environments/test.rb +1 -1
  69. data/test/dummy/config/initializers/omniauth.rb +2 -2
  70. data/test/dummy/config/routes.rb +10 -29
  71. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +8 -8
  72. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +7 -7
  73. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +4 -4
  74. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +7 -7
  75. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +7 -7
  76. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +7 -7
  77. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +6 -6
  78. data/test/dummy/db/schema.rb +2 -60
  79. data/test/factories/users.rb +40 -0
  80. data/test/lib/devise_token_auth/url_test.rb +6 -6
  81. data/test/lib/generators/devise_token_auth/install_generator_test.rb +22 -14
  82. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +30 -22
  83. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +1 -1
  84. data/test/models/user_test.rb +15 -46
  85. data/test/support/controllers/routes.rb +43 -0
  86. data/test/test_helper.rb +12 -12
  87. metadata +8 -14
  88. data/test/dummy/app/models/evil_user.rb +0 -5
  89. data/test/dummy/app/models/nice_user.rb +0 -9
  90. data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +0 -66
  91. data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +0 -63
  92. data/test/integration/navigation_test.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a953783eff82cbde0a065ca2584f23643f1c8f2
4
- data.tar.gz: 2352f6967f0b98a4820cfee2bb018a0cec03e2a9
3
+ metadata.gz: b4979d300ecd6cc6549803714b7737e897bca1ad
4
+ data.tar.gz: 1b73b2890e2f654812585cfeded1f7b682267b36
5
5
  SHA512:
6
- metadata.gz: 476435f1a4543e96af97cd46768ad59d2779f0da6c162e07fe30edd3a39b2453bba8cee2e12593d785db9487374c59f1350118c9730e87764feae312a35049b3
7
- data.tar.gz: 959f6d1aff53512992a3a5bab172512ae8796972b0d2207f979a8300b772d2611556a7be7265224bcc04dc0bb83bdc2bd2342485bb2da20f3aab361e61d5866d
6
+ metadata.gz: 38f0c132610a90f5e5a23d31c596e43eddbdc640deaf7a5c003901895c4045afabdc9c238e044519be04616ecc62765bf23b149c8e888d7a258e9620259c2ad0
7
+ data.tar.gz: e6cb430221c6a9218bbdf85d5bba1026d5eff253503bc3c517c1ff1bff4b36d7cde279ecc8e50810455576cfad81ac9d12594e02224fe9666ae15172a1473d8c
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Build Status](https://travis-ci.org/lynndylanhurley/devise_token_auth.svg?branch=master)](https://travis-ci.org/lynndylanhurley/devise_token_auth)
5
5
  [![Code Climate](https://codeclimate.com/github/lynndylanhurley/devise_token_auth/badges/gpa.svg)](https://codeclimate.com/github/lynndylanhurley/devise_token_auth)
6
6
  [![Test Coverage](https://codeclimate.com/github/lynndylanhurley/devise_token_auth/badges/coverage.svg)](https://codeclimate.com/github/lynndylanhurley/devise_token_auth/coverage)
7
- [![Dependency Status](https://gemnasium.com/lynndylanhurley/devise_token_auth.svg)](https://gemnasium.com/lynndylanhurley/devise_token_auth)
8
7
  [![Downloads](https://img.shields.io/gem/dt/devise_token_auth.svg)](https://rubygems.org/gems/devise_token_auth)
9
8
  [![Backers on Open Collective](https://opencollective.com/devise_token_auth/backers/badge.svg)](#backers)
10
9
  [![Sponsors on Open Collective](https://opencollective.com/devise_token_auth/sponsors/badge.svg)](#sponsors)
@@ -50,7 +49,7 @@ Then install the gem using bundle:
50
49
  bundle install
51
50
  ~~~
52
51
 
53
- ## [Docs](https://maicolben.gitbooks.io/devise-token-auth/content/docs/config/)
52
+ ## [Docs](https://devise-token-auth.gitbook.io/devise-token-auth)
54
53
 
55
54
  ## Need help?
56
55
 
data/Rakefile CHANGED
@@ -16,11 +16,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_files.include('lib/**/*.rb')
17
17
  end
18
18
 
19
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
20
20
  load 'rails/tasks/engine.rake'
21
21
 
22
-
23
-
24
22
  Bundler::GemHelper.install_tasks
25
23
 
26
24
  require 'rake/testtask'
@@ -33,5 +31,12 @@ Rake::TestTask.new(:test) do |t|
33
31
  t.warning = false
34
32
  end
35
33
 
36
-
37
34
  task default: :test
35
+
36
+ require 'rubocop/rake_task'
37
+
38
+ desc 'Run RuboCop'
39
+ RuboCop::RakeTask.new(:rubocop) do |task|
40
+ task.formatters = %w[fuubar offenses worst]
41
+ task.fail_on_error = false # don't abort rake on failure
42
+ end
@@ -5,16 +5,14 @@ module DeviseTokenAuth
5
5
  include DeviseTokenAuth::Concerns::SetUserByToken
6
6
  include DeviseTokenAuth::Concerns::ResourceFinder
7
7
 
8
- def resource_data(opts={})
8
+ def resource_data(opts = {})
9
9
  response_data = opts[:resource_json] || @resource.as_json
10
- if json_api?
11
- response_data['type'] = @resource.class.name.parameterize
12
- end
10
+ response_data['type'] = @resource.class.name.parameterize if json_api?
13
11
  response_data
14
12
  end
15
13
 
16
14
  def resource_errors
17
- return @resource.errors.to_hash.merge(full_messages: @resource.errors.full_messages)
15
+ @resource.errors.to_hash.merge(full_messages: @resource.errors.full_messages)
18
16
  end
19
17
 
20
18
  protected
@@ -44,7 +42,7 @@ module DeviseTokenAuth
44
42
  devise_parameter_sanitizer.instance_values['permitted'][resource]
45
43
  end
46
44
 
47
- def resource_class(m=nil)
45
+ def resource_class(m = nil)
48
46
  if m
49
47
  mapping = Devise.mappings[m]
50
48
  else
@@ -59,7 +57,7 @@ module DeviseTokenAuth
59
57
  return ActiveModel::Serializer.setup do |config|
60
58
  config.adapter == :json_api
61
59
  end if ActiveModel::Serializer.respond_to?(:setup)
62
- return ActiveModelSerializers.config.adapter == :json_api
60
+ ActiveModelSerializers.config.adapter == :json_api
63
61
  end
64
62
 
65
63
  def recoverable_enabled?
@@ -23,13 +23,13 @@ module DeviseTokenAuth::Concerns::ResourceFinder
23
23
  # fix for mysql default case insensitivity
24
24
  q = "#{field.to_s} = ? AND provider='#{provider.to_s}'"
25
25
  if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql'
26
- q = "BINARY " + q
26
+ q = 'BINARY ' + q
27
27
  end
28
28
 
29
29
  @resource = resource_class.where(q, value).first
30
30
  end
31
31
 
32
- def resource_class(m=nil)
32
+ def resource_class(m = nil)
33
33
  if m
34
34
  mapping = Devise.mappings[m]
35
35
  else
@@ -36,7 +36,7 @@ module DeviseTokenAuth::Concerns::SetUserByToken
36
36
  end
37
37
 
38
38
  # user auth
39
- def set_user_by_token(mapping=nil)
39
+ def set_user_by_token(mapping = nil)
40
40
  # determine target authentication class
41
41
  rc = resource_class(mapping)
42
42
 
@@ -72,7 +72,7 @@ module DeviseTokenAuth::Concerns::SetUserByToken
72
72
  return @resource if @resource && @resource.is_a?(rc)
73
73
 
74
74
  # ensure we clear the client_id
75
- if !@token
75
+ unless @token
76
76
  @client_id = nil
77
77
  return
78
78
  end
@@ -84,7 +84,7 @@ module DeviseTokenAuth::Concerns::SetUserByToken
84
84
 
85
85
  if user && user.valid_token?(@token, @client_id)
86
86
  # sign_in with bypass: true will be deprecated in the next version of Devise
87
- if self.respond_to?(:bypass_sign_in) && DeviseTokenAuth.bypass_sign_in
87
+ if respond_to?(:bypass_sign_in) && DeviseTokenAuth.bypass_sign_in
88
88
  bypass_sign_in(user, scope: :user)
89
89
  else
90
90
  sign_in(:user, user, store: false, event: :fetch, bypass: DeviseTokenAuth.bypass_sign_in)
@@ -135,13 +135,22 @@ module DeviseTokenAuth::Concerns::SetUserByToken
135
135
  if @is_batch_request
136
136
  auth_header = @resource.extend_batch_buffer(@token, @client_id)
137
137
 
138
+ # Do not return token for batch requests to avoid invalidated
139
+ # tokens returned to the client in case of race conditions.
140
+ # Use a blank string for the header to still be present and
141
+ # being passed in a XHR response in case of
142
+ # 304 Not Modified responses.
143
+ auth_header[DeviseTokenAuth.headers_names[:"access-token"]] = ' '
144
+ auth_header[DeviseTokenAuth.headers_names[:"expiry"]] = ' '
145
+
138
146
  # update Authorization response header with new token
139
147
  else
140
148
  auth_header = @resource.create_new_auth_token(@client_id)
141
-
142
- # update the response header
143
- response.headers.merge!(auth_header)
144
149
  end
150
+
151
+ # update the response header
152
+ response.headers.merge!(auth_header)
153
+
145
154
  end # end lock
146
155
  end # end ensure_pristine_resource
147
156
  end
@@ -150,11 +159,10 @@ module DeviseTokenAuth::Concerns::SetUserByToken
150
159
 
151
160
  private
152
161
 
153
-
154
162
  def is_batch_request?(user, client_id)
155
163
  !params[:unbatch] &&
156
- user.tokens[client_id] &&
157
- user.tokens[client_id]['updated_at'] &&
158
- Time.parse(user.tokens[client_id]['updated_at']) > @request_started_at - DeviseTokenAuth.batch_request_buffer_throttle
164
+ user.tokens[client_id] &&
165
+ user.tokens[client_id]['updated_at'] &&
166
+ Time.parse(user.tokens[client_id]['updated_at']) > @request_started_at - DeviseTokenAuth.batch_request_buffer_throttle
159
167
  end
160
168
  end
@@ -18,14 +18,14 @@ module DeviseTokenAuth
18
18
 
19
19
  yield @resource if block_given?
20
20
 
21
- redirect_header_options = {account_confirmation_success: true}
21
+ redirect_header_options = { account_confirmation_success: true }
22
22
  redirect_headers = build_redirect_headers(token,
23
23
  client_id,
24
24
  redirect_header_options)
25
25
  redirect_to(@resource.build_auth_url(params[:redirect_url],
26
26
  redirect_headers))
27
27
  else
28
- raise ActionController::RoutingError.new('Not Found')
28
+ raise ActionController::RoutingError, 'Not Found'
29
29
  end
30
30
  end
31
31
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module DeviseTokenAuth
4
4
  class OmniauthCallbacksController < DeviseTokenAuth::ApplicationController
5
-
6
5
  attr_reader :auth_params
7
6
  skip_before_action :set_user_by_token, raise: false
8
7
  skip_after_action :update_auth_header
@@ -48,7 +47,7 @@ module DeviseTokenAuth
48
47
 
49
48
  def omniauth_failure
50
49
  @error = params[:message]
51
- render_data_or_redirect('authFailure', {error: @error})
50
+ render_data_or_redirect('authFailure', error: @error)
52
51
  end
53
52
 
54
53
  protected
@@ -62,7 +61,7 @@ module DeviseTokenAuth
62
61
  # after use. In the failure case, finally, the omniauth params
63
62
  # are added as query params in our monkey patch to OmniAuth in engine.rb
64
63
  def omniauth_params
65
- if !defined?(@_omniauth_params)
64
+ unless defined?(@_omniauth_params)
66
65
  if request.env['omniauth.params'] && request.env['omniauth.params'].any?
67
66
  @_omniauth_params = request.env['omniauth.params']
68
67
  elsif session['dta.omniauth.params'] && session['dta.omniauth.params'].any?
@@ -88,13 +87,11 @@ module DeviseTokenAuth
88
87
  def whitelisted_params
89
88
  whitelist = params_for_resource(:sign_up)
90
89
 
91
- whitelist.inject({}){|coll, key|
90
+ whitelist.inject({}) do |coll, key|
92
91
  param = omniauth_params[key.to_s]
93
- if param
94
- coll[key] = param
95
- end
92
+ coll[key] = param if param
96
93
  coll
97
- }
94
+ end
98
95
  end
99
96
 
100
97
  def resource_class(mapping = nil)
@@ -103,7 +100,7 @@ module DeviseTokenAuth
103
100
  elsif params['resource_class']
104
101
  params['resource_class'].constantize
105
102
  else
106
- raise "No resource_class found"
103
+ raise 'No resource_class found'
107
104
  end
108
105
  end
109
106
 
@@ -151,10 +148,10 @@ module DeviseTokenAuth
151
148
 
152
149
  def set_random_password
153
150
  # set crazy password for new oauth users. this is only used to prevent
154
- # access via email sign-in.
155
- p = SecureRandom.urlsafe_base64(nil, false)
156
- @resource.password = p
157
- @resource.password_confirmation = p
151
+ # access via email sign-in.
152
+ p = SecureRandom.urlsafe_base64(nil, false)
153
+ @resource.password = p
154
+ @resource.password_confirmation = p
158
155
  end
159
156
 
160
157
  def create_auth_params
@@ -175,10 +172,8 @@ module DeviseTokenAuth
175
172
  end
176
173
 
177
174
  def render_data(message, data)
178
- @data = data.merge({
179
- message: message
180
- })
181
- render :layout => nil, :template => "devise_token_auth/omniauth_external_window"
175
+ @data = data.merge(message: message)
176
+ render layout: nil, template: 'devise_token_auth/omniauth_external_window'
182
177
  end
183
178
 
184
179
  def render_data_or_redirect(message, data, user_data = {})
@@ -209,22 +204,22 @@ module DeviseTokenAuth
209
204
  end
210
205
 
211
206
  def fallback_render(text)
212
- render inline: %Q|
207
+ render inline: %Q(
213
208
 
214
209
  <html>
215
210
  <head></head>
216
211
  <body>
217
212
  #{text}
218
213
  </body>
219
- </html>|
214
+ </html>)
220
215
  end
221
216
 
222
217
  def get_resource_from_auth_hash
223
218
  # find or create user by provider and provider uid
224
- @resource = resource_class.where({
225
- uid: auth_hash['uid'],
219
+ @resource = resource_class.where(
220
+ uid: auth_hash['uid'],
226
221
  provider: auth_hash['provider']
227
- }).first_or_initialize
222
+ ).first_or_initialize
228
223
 
229
224
  if @resource.new_record?
230
225
  @oauth_registration = true
@@ -240,6 +235,5 @@ module DeviseTokenAuth
240
235
 
241
236
  @resource
242
237
  end
243
-
244
238
  end
245
239
  end
@@ -2,21 +2,19 @@
2
2
 
3
3
  module DeviseTokenAuth
4
4
  class PasswordsController < DeviseTokenAuth::ApplicationController
5
- before_action :set_user_by_token, :only => [:update]
6
- skip_after_action :update_auth_header, :only => [:create, :edit]
5
+ before_action :set_user_by_token, only: [:update]
6
+ skip_after_action :update_auth_header, only: [:create, :edit]
7
7
 
8
8
  # this action is responsible for generating password reset tokens and
9
9
  # sending emails
10
10
  def create
11
- unless resource_params[:email]
12
- return render_create_error_missing_email
13
- end
11
+ return render_create_error_missing_email unless resource_params[:email]
14
12
 
15
13
  # give redirect value from params priority
16
14
  @redirect_url = params.fetch(
17
- :redirect_url,
18
- DeviseTokenAuth.default_password_reset_url
19
- )
15
+ :redirect_url,
16
+ DeviseTokenAuth.default_password_reset_url
17
+ )
20
18
 
21
19
  return render_create_error_missing_redirect_url unless @redirect_url
22
20
  return render_create_error_not_allowed_redirect_url if blacklisted_redirect_url?
@@ -26,12 +24,12 @@ module DeviseTokenAuth
26
24
 
27
25
  if @resource
28
26
  yield @resource if block_given?
29
- @resource.send_reset_password_instructions({
27
+ @resource.send_reset_password_instructions(
30
28
  email: @email,
31
29
  provider: 'email',
32
30
  redirect_url: @redirect_url,
33
31
  client_config: params[:config_name]
34
- })
32
+ )
35
33
 
36
34
  if @resource.errors.empty?
37
35
  return render_create_success
@@ -61,7 +59,7 @@ module DeviseTokenAuth
61
59
 
62
60
  yield @resource if block_given?
63
61
 
64
- redirect_header_options = {reset_password: true}
62
+ redirect_header_options = { reset_password: true }
65
63
  redirect_headers = build_redirect_headers(token,
66
64
  client_id,
67
65
  redirect_header_options)
@@ -74,9 +72,7 @@ module DeviseTokenAuth
74
72
 
75
73
  def update
76
74
  # make sure user is authorized
77
- unless @resource
78
- return render_update_error_unauthorized
79
- end
75
+ return render_update_error_unauthorized unless @resource
80
76
 
81
77
  # make sure account doesn't use oauth2 provider
82
78
  unless @resource.provider == 'email'
@@ -104,18 +100,18 @@ module DeviseTokenAuth
104
100
  def resource_update_method
105
101
  allow_password_change = recoverable_enabled? && @resource.allow_password_change == true
106
102
  if DeviseTokenAuth.check_current_password_before_update == false || allow_password_change
107
- "update_attributes"
103
+ 'update_attributes'
108
104
  else
109
- "update_with_password"
105
+ 'update_with_password'
110
106
  end
111
107
  end
112
108
 
113
109
  def render_create_error_missing_email
114
- render_error(401, I18n.t("devise_token_auth.passwords.missing_email"))
110
+ render_error(401, I18n.t('devise_token_auth.passwords.missing_email'))
115
111
  end
116
112
 
117
113
  def render_create_error_missing_redirect_url
118
- render_error(401, I18n.t("devise_token_auth.passwords.missing_redirect_url"))
114
+ render_error(401, I18n.t('devise_token_auth.passwords.missing_redirect_url'))
119
115
  end
120
116
 
121
117
  def render_create_error_not_allowed_redirect_url
@@ -123,26 +119,26 @@ module DeviseTokenAuth
123
119
  status: 'error',
124
120
  data: resource_data
125
121
  }
126
- message = I18n.t("devise_token_auth.passwords.not_allowed_redirect_url", redirect_url: @redirect_url)
122
+ message = I18n.t('devise_token_auth.passwords.not_allowed_redirect_url', redirect_url: @redirect_url)
127
123
  render_error(422, message, response)
128
124
  end
129
125
 
130
126
  def render_create_success
131
127
  render json: {
132
128
  success: true,
133
- message: I18n.t("devise_token_auth.passwords.sended", email: @email)
129
+ message: I18n.t('devise_token_auth.passwords.sended', email: @email)
134
130
  }
135
131
  end
136
132
 
137
133
  def render_create_error(errors)
138
134
  render json: {
139
135
  success: false,
140
- errors: errors,
136
+ errors: errors
141
137
  }, status: 400
142
138
  end
143
139
 
144
140
  def render_edit_error
145
- raise ActionController::RoutingError.new('Not Found')
141
+ raise ActionController::RoutingError, 'Not Found'
146
142
  end
147
143
 
148
144
  def render_update_error_unauthorized
@@ -150,23 +146,23 @@ module DeviseTokenAuth
150
146
  end
151
147
 
152
148
  def render_update_error_password_not_required
153
- render_error(422, I18n.t("devise_token_auth.passwords.password_not_required", provider: @resource.provider.humanize))
149
+ render_error(422, I18n.t('devise_token_auth.passwords.password_not_required', provider: @resource.provider.humanize))
154
150
  end
155
151
 
156
152
  def render_update_error_missing_password
157
- render_error(422, I18n.t("devise_token_auth.passwords.missing_passwords"))
153
+ render_error(422, I18n.t('devise_token_auth.passwords.missing_passwords'))
158
154
  end
159
155
 
160
156
  def render_update_success
161
157
  render json: {
162
158
  success: true,
163
159
  data: resource_data,
164
- message: I18n.t("devise_token_auth.passwords.successfully_updated")
160
+ message: I18n.t('devise_token_auth.passwords.successfully_updated')
165
161
  }
166
162
  end
167
163
 
168
164
  def render_update_error
169
- return render json: {
165
+ render json: {
170
166
  success: false,
171
167
  errors: resource_errors
172
168
  }, status: 422
@@ -190,7 +186,7 @@ module DeviseTokenAuth
190
186
  end
191
187
 
192
188
  def render_not_found_error
193
- render_error(404, I18n.t("devise_token_auth.passwords.user_not_found", email: @email))
189
+ render_error(404, I18n.t('devise_token_auth.passwords.user_not_found', email: @email))
194
190
  end
195
191
  end
196
192
  end