sorcery 0.12.0 → 0.13.0

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

Potentially problematic release.


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

Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +20 -0
  3. data/.rubocop.yml +52 -2
  4. data/.rubocop_todo.yml +1 -429
  5. data/.travis.yml +11 -21
  6. data/CHANGELOG.md +16 -0
  7. data/Gemfile +2 -2
  8. data/{LICENSE.txt → LICENSE.md} +1 -1
  9. data/README.md +7 -1
  10. data/gemfiles/{active_record-rails40.gemfile → active_record_rails_40.gemfile} +1 -2
  11. data/gemfiles/{active_record-rails41.gemfile → active_record_rails_41.gemfile} +1 -2
  12. data/gemfiles/{active_record-rails42.gemfile → active_record_rails_42.gemfile} +1 -2
  13. data/lib/generators/sorcery/USAGE +1 -1
  14. data/lib/generators/sorcery/install_generator.rb +21 -21
  15. data/lib/generators/sorcery/templates/initializer.rb +19 -1
  16. data/lib/sorcery/adapters/active_record_adapter.rb +1 -1
  17. data/lib/sorcery/adapters/mongoid_adapter.rb +23 -11
  18. data/lib/sorcery/controller.rb +22 -16
  19. data/lib/sorcery/controller/config.rb +2 -0
  20. data/lib/sorcery/controller/submodules/activity_logging.rb +4 -0
  21. data/lib/sorcery/controller/submodules/external.rb +37 -33
  22. data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -0
  23. data/lib/sorcery/controller/submodules/remember_me.rb +1 -7
  24. data/lib/sorcery/controller/submodules/session_timeout.rb +25 -4
  25. data/lib/sorcery/crypto_providers/aes256.rb +1 -0
  26. data/lib/sorcery/crypto_providers/bcrypt.rb +2 -1
  27. data/lib/sorcery/engine.rb +10 -3
  28. data/lib/sorcery/model.rb +9 -6
  29. data/lib/sorcery/model/config.rb +3 -3
  30. data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -7
  31. data/lib/sorcery/model/submodules/external.rb +4 -3
  32. data/lib/sorcery/model/submodules/magic_login.rb +29 -36
  33. data/lib/sorcery/model/submodules/reset_password.rb +5 -4
  34. data/lib/sorcery/model/submodules/user_activation.rb +1 -1
  35. data/lib/sorcery/protocols/oauth.rb +1 -0
  36. data/lib/sorcery/providers/auth0.rb +46 -0
  37. data/lib/sorcery/providers/heroku.rb +1 -0
  38. data/lib/sorcery/providers/instagram.rb +73 -0
  39. data/lib/sorcery/providers/linkedin.rb +1 -1
  40. data/lib/sorcery/providers/vk.rb +1 -1
  41. data/lib/sorcery/providers/wechat.rb +8 -6
  42. data/lib/sorcery/test_helpers/internal.rb +5 -4
  43. data/lib/sorcery/test_helpers/internal/rails.rb +11 -11
  44. data/lib/sorcery/version.rb +1 -1
  45. data/sorcery.gemspec +25 -9
  46. data/spec/active_record/user_activation_spec.rb +2 -2
  47. data/spec/active_record/user_activity_logging_spec.rb +2 -2
  48. data/spec/active_record/user_brute_force_protection_spec.rb +2 -2
  49. data/spec/active_record/user_magic_login_spec.rb +4 -4
  50. data/spec/active_record/user_oauth_spec.rb +2 -2
  51. data/spec/active_record/user_remember_me_spec.rb +2 -2
  52. data/spec/active_record/user_reset_password_spec.rb +2 -2
  53. data/spec/active_record/user_spec.rb +0 -10
  54. data/spec/controllers/controller_http_basic_auth_spec.rb +1 -1
  55. data/spec/controllers/controller_oauth2_spec.rb +195 -123
  56. data/spec/controllers/controller_oauth_spec.rb +7 -7
  57. data/spec/controllers/controller_remember_me_spec.rb +11 -6
  58. data/spec/controllers/controller_session_timeout_spec.rb +90 -3
  59. data/spec/controllers/controller_spec.rb +2 -2
  60. data/spec/orm/active_record.rb +2 -2
  61. data/spec/providers/vk_spec.rb +13 -12
  62. data/spec/rails_app/app/controllers/sorcery_controller.rb +83 -32
  63. data/spec/rails_app/app/mailers/sorcery_mailer.rb +1 -1
  64. data/spec/rails_app/config/application.rb +8 -3
  65. data/spec/rails_app/config/boot.rb +1 -1
  66. data/spec/rails_app/config/environment.rb +1 -1
  67. data/spec/rails_app/config/routes.rb +7 -0
  68. data/spec/rails_app/config/secrets.yml +4 -0
  69. data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -2
  70. data/spec/rails_app/db/migrate/invalidate_active_sessions/20180221093235_add_invalidate_active_sessions_before_to_users.rb +9 -0
  71. data/spec/rails_app/db/migrate/magic_login/20170924151831_add_magic_login_to_users.rb +3 -3
  72. data/spec/rails_app/db/schema.rb +7 -9
  73. data/spec/shared_examples/user_magic_login_shared_examples.rb +50 -50
  74. data/spec/shared_examples/user_oauth_shared_examples.rb +1 -1
  75. data/spec/shared_examples/user_remember_me_shared_examples.rb +1 -1
  76. data/spec/shared_examples/user_reset_password_shared_examples.rb +3 -3
  77. data/spec/shared_examples/user_shared_examples.rb +41 -43
  78. data/spec/sorcery_crypto_providers_spec.rb +1 -1
  79. data/spec/spec.opts +1 -1
  80. data/spec/spec_helper.rb +2 -2
  81. data/spec/support/migration_helper.rb +19 -0
  82. metadata +60 -38
  83. data/spec/rails_app/config/initializers/secret_token.rb +0 -7
@@ -20,7 +20,7 @@ def stub_all_oauth_requests!
20
20
  'in_reply_to_status_id_str' => nil, 'created_at' => 'Sun Mar 06 23:01:12 +0000 2011',
21
21
  'contributors' => nil, 'place' => nil, 'retweeted' => false, 'in_reply_to_status_id' => nil,
22
22
  'in_reply_to_user_id_str' => nil, 'coordinates' => nil, 'retweet_count' => 0,
23
- 'id' => 44533012284706816, 'id_str' => '44533012284706816'
23
+ 'id' => 44_533_012_284_706_816, 'id_str' => '44533012284706816'
24
24
  },
25
25
  'show_all_inline_media' => false, 'geo_enabled' => true,
26
26
  'profile_sidebar_border_color' => 'a8c7f7', 'url' => nil, 'followers_count' => 10,
@@ -32,7 +32,7 @@ def stub_all_oauth_requests!
32
32
  'is_translator' => false, 'contributors_enabled' => false, 'protected' => false,
33
33
  'follow_request_sent' => false, 'time_zone' => 'Greenland', 'profile_text_color' => '333333',
34
34
  'name' => 'Noam Ben Ari', 'friends_count' => 10, 'profile_sidebar_fill_color' => 'C0DFEC',
35
- 'id' => 123, 'id_str' => '91434812', 'profile_background_tile' => false, 'utc_offset' => -10800
35
+ 'id' => 123, 'id_str' => '91434812', 'profile_background_tile' => false, 'utc_offset' => -10_800
36
36
  }.to_json
37
37
 
38
38
  session[:request_token] = req_token.token
@@ -50,7 +50,7 @@ describe SorceryController, type: :controller do
50
50
 
51
51
  before(:all) do
52
52
  sorcery_reload!([:external])
53
- sorcery_controller_property_set(:external_providers, [:twitter, :jira])
53
+ sorcery_controller_property_set(:external_providers, %i[twitter jira])
54
54
  sorcery_controller_external_property_set(:twitter, :key, 'eYVNBjBDi33aa9GkA3w')
55
55
  sorcery_controller_external_property_set(:twitter, :secret, 'XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8')
56
56
  sorcery_controller_external_property_set(:twitter, :callback_url, 'http://blabla.com')
@@ -179,7 +179,7 @@ describe SorceryController, type: :controller do
179
179
 
180
180
  describe SorceryController, 'OAuth with user activation features' do
181
181
  before(:all) do
182
- sorcery_reload!([:activity_logging, :external])
182
+ sorcery_reload!(%i[activity_logging external])
183
183
  end
184
184
 
185
185
  context 'when twitter' do
@@ -215,16 +215,16 @@ describe SorceryController, type: :controller do
215
215
  describe SorceryController, 'OAuth with session timeout features' do
216
216
  before(:all) do
217
217
  if SORCERY_ORM == :active_record
218
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
218
+ MigrationHelper.migrate("#{Rails.root}/db/migrate/external")
219
219
  User.reset_column_information
220
220
  end
221
221
 
222
- sorcery_reload!([:session_timeout, :external])
222
+ sorcery_reload!(%i[session_timeout external])
223
223
  end
224
224
 
225
225
  after(:all) do
226
226
  if SORCERY_ORM == :active_record
227
- ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
227
+ MigrationHelper.rollback("#{Rails.root}/db/migrate/external")
228
228
  end
229
229
  end
230
230
 
@@ -9,10 +9,11 @@ describe SorceryController, type: :controller do
9
9
  sorcery_reload!([:remember_me])
10
10
  end
11
11
 
12
- after(:each) do
13
- session = nil
14
- cookies = nil
15
- end
12
+ # TODO: Unused, remove?
13
+ # after(:each) do
14
+ # session = nil
15
+ # cookies = nil
16
+ # end
16
17
 
17
18
  before(:each) do
18
19
  allow(user).to receive(:remember_me_token)
@@ -31,16 +32,18 @@ describe SorceryController, type: :controller do
31
32
  end
32
33
 
33
34
  it 'clears cookie on forget_me!' do
34
- cookies['remember_me_token'] == { value: 'asd54234dsfsd43534', expires: 3600 }
35
+ cookies['remember_me_token'] = { value: 'asd54234dsfsd43534', expires: 3600 }
35
36
  get :test_logout
36
37
 
38
+ pending 'Test previously broken, functionality might not be working here.'
37
39
  expect(cookies['remember_me_token']).to be_nil
38
40
  end
39
41
 
40
42
  it 'clears cookie on force_forget_me!' do
41
- cookies['remember_me_token'] == { value: 'asd54234dsfsd43534', expires: 3600 }
43
+ cookies['remember_me_token'] = { value: 'asd54234dsfsd43534', expires: 3600 }
42
44
  get :test_logout_with_force_forget_me
43
45
 
46
+ pending 'Test previously broken, functionality might not be working here.'
44
47
  expect(cookies['remember_me_token']).to be_nil
45
48
  end
46
49
 
@@ -80,6 +83,8 @@ describe SorceryController, type: :controller do
80
83
 
81
84
  expect(User.sorcery_adapter).to receive(:find_by_remember_me_token).with('token').and_return(user)
82
85
 
86
+ expect(subject).to receive(:after_remember_me!).with(user)
87
+
83
88
  get :test_login_from_cookie
84
89
 
85
90
  expect(assigns[:current_user]).to eq user
@@ -24,7 +24,7 @@ describe SorceryController, type: :controller do
24
24
  get :test_should_be_logged_in
25
25
 
26
26
  expect(session[:user_id]).not_to be_nil
27
- expect(response).to be_a_success
27
+ expect(response).to be_successful
28
28
  end
29
29
 
30
30
  it 'resets session after session timeout' do
@@ -36,6 +36,87 @@ describe SorceryController, type: :controller do
36
36
  expect(response).to be_a_redirect
37
37
  end
38
38
 
39
+ context "with 'invalidate_active_sessions_enabled'" do
40
+ it 'does not reset the session if invalidate_sessions_before is nil' do
41
+ sorcery_controller_property_set(:session_timeout_invalidate_active_sessions_enabled, true)
42
+ login_user user
43
+ allow(user).to receive(:invalidate_sessions_before) { nil }
44
+
45
+ get :test_should_be_logged_in
46
+
47
+ expect(session[:user_id]).not_to be_nil
48
+ expect(response).to be_successful
49
+ end
50
+
51
+ it 'does not reset the session if it was not created before invalidate_sessions_before' do
52
+ sorcery_controller_property_set(:session_timeout_invalidate_active_sessions_enabled, true)
53
+ login_user user
54
+ allow(user).to receive(:invalidate_sessions_before) { Time.now.in_time_zone - 10.minutes }
55
+
56
+ get :test_should_be_logged_in
57
+
58
+ expect(session[:user_id]).not_to be_nil
59
+ expect(response).to be_successful
60
+ end
61
+
62
+ it 'resets the session if the session was created before invalidate_sessions_before' do
63
+ sorcery_controller_property_set(:session_timeout_invalidate_active_sessions_enabled, true)
64
+ login_user user
65
+ allow(user).to receive(:invalidate_sessions_before) { Time.now.in_time_zone }
66
+ get :test_should_be_logged_in
67
+
68
+ expect(session[:user_id]).to be_nil
69
+ expect(response).to be_a_redirect
70
+ end
71
+
72
+ it 'resets active sessions on next action if invalidate_active_sessions! is called' do
73
+ sorcery_controller_property_set(:session_timeout_invalidate_active_sessions_enabled, true)
74
+ # precondition that the user is logged in
75
+ login_user user
76
+ get :test_should_be_logged_in
77
+ expect(response).to be_successful
78
+
79
+ allow(user).to receive(:send) { |_method, value| allow(user).to receive(:invalidate_sessions_before) { value } }
80
+ allow(user).to receive(:save)
81
+ get :test_invalidate_active_session
82
+ expect(response).to be_successful
83
+
84
+ get :test_should_be_logged_in
85
+ expect(session[:user_id]).to be_nil
86
+ expect(response).to be_a_redirect
87
+ end
88
+
89
+ it 'allows login after invalidate_active_sessions! is called' do
90
+ sorcery_controller_property_set(:session_timeout_invalidate_active_sessions_enabled, true)
91
+ # precondition that the user is logged in
92
+ login_user user
93
+ get :test_should_be_logged_in
94
+ expect(response).to be_successful
95
+
96
+ allow(user).to receive(:send) { |_method, value| allow(user).to receive(:invalidate_sessions_before) { value } }
97
+ allow(user).to receive(:save)
98
+ # Call to invalidate
99
+ get :test_invalidate_active_session
100
+ expect(response).to be_successful
101
+
102
+ # Check that existing sessions were logged out
103
+ get :test_should_be_logged_in
104
+ expect(session[:user_id]).to be_nil
105
+ expect(response).to be_a_redirect
106
+
107
+ # Check that new session is allowed to login
108
+ login_user user
109
+ get :test_should_be_logged_in
110
+ expect(response).to be_successful
111
+ expect(session[:user_id]).not_to be_nil
112
+
113
+ # Check an additional request to make sure not logged out on next request
114
+ get :test_should_be_logged_in
115
+ expect(response).to be_successful
116
+ expect(session[:user_id]).not_to be_nil
117
+ end
118
+ end
119
+
39
120
  it 'works if the session is stored as a string or a Time' do
40
121
  session[:login_time] = Time.now.to_s
41
122
  # TODO: ???
@@ -44,7 +125,7 @@ describe SorceryController, type: :controller do
44
125
  get :test_login, params: { email: 'bla@bla.com', password: 'secret' }
45
126
 
46
127
  expect(session[:user_id]).not_to be_nil
47
- expect(response).to be_a_success
128
+ expect(response).to be_successful
48
129
  end
49
130
 
50
131
  context "with 'session_timeout_from_last_action'" do
@@ -62,7 +143,7 @@ describe SorceryController, type: :controller do
62
143
  get :test_should_be_logged_in
63
144
 
64
145
  expect(session[:user_id]).not_to be_nil
65
- expect(response).to be_a_success
146
+ expect(response).to be_successful
66
147
  end
67
148
 
68
149
  it "with 'session_timeout_from_last_action' logs out if there was no activity" do
@@ -75,5 +156,11 @@ describe SorceryController, type: :controller do
75
156
  expect(response).to be_a_redirect
76
157
  end
77
158
  end
159
+
160
+ it 'registers login time on remember_me callback' do
161
+ expect(subject).to receive(:register_login_time).with(user)
162
+
163
+ subject.send(:after_remember_me!, user)
164
+ end
78
165
  end
79
166
  end
@@ -132,7 +132,7 @@ describe SorceryController, type: :controller do
132
132
  sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
133
133
  get :test_logout
134
134
 
135
- expect(response).to be_a_success
135
+ expect(response).to be_successful
136
136
  end
137
137
 
138
138
  it 'require_login before_action saves the url that the user originally wanted' do
@@ -143,7 +143,7 @@ describe SorceryController, type: :controller do
143
143
  end
144
144
 
145
145
  it 'require_login before_action does not save the url that the user originally wanted upon all non-get http methods' do
146
- [:post, :put, :delete].each do |m|
146
+ %i[post put delete].each do |m|
147
147
  send(m, :some_action)
148
148
 
149
149
  expect(session[:return_to_url]).to be_nil
@@ -9,11 +9,11 @@ class TestUser < ActiveRecord::Base
9
9
  end
10
10
 
11
11
  def setup_orm
12
- ActiveRecord::Migrator.migrate(migrations_path)
12
+ MigrationHelper.migrate(migrations_path)
13
13
  end
14
14
 
15
15
  def teardown_orm
16
- ActiveRecord::Migrator.rollback(migrations_path)
16
+ MigrationHelper.rollback(migrations_path)
17
17
  end
18
18
 
19
19
  def migrations_path
@@ -11,25 +11,27 @@ describe Sorcery::Providers::Vk do
11
11
  before(:all) do
12
12
  sorcery_reload!([:external])
13
13
  sorcery_controller_property_set(:external_providers, [:vk])
14
- sorcery_controller_external_property_set(:vk, :key, "KEY")
15
- sorcery_controller_external_property_set(:vk, :secret, "SECRET")
14
+ sorcery_controller_external_property_set(:vk, :key, 'KEY')
15
+ sorcery_controller_external_property_set(:vk, :secret, 'SECRET')
16
16
  end
17
17
 
18
18
  def stub_vk_authorize
19
- stub_request(:post, /https\:\/\/oauth\.vk\.com\/access_token/)
20
- .to_return(
21
- status: 200,
22
- body: '{"access_token":"TOKEN","expires_in":86329,"user_id":1}',
23
- headers: {'content-type' => 'application/json'})
19
+ stub_request(:post, %r{https\:\/\/oauth\.vk\.com\/access_token}).to_return(
20
+ status: 200,
21
+ body: '{"access_token":"TOKEN","expires_in":86329,"user_id":1}',
22
+ headers: { 'content-type' => 'application/json' }
23
+ )
24
24
  end
25
25
 
26
- context "getting user info hash" do
27
- it "should provide VK API version" do
26
+ context 'getting user info hash' do
27
+ it 'should provide VK API version' do
28
28
  stub_vk_authorize
29
29
  sorcery_controller_external_property_set(:vk, :api_version, '5.71')
30
30
 
31
- get_user = stub_request(:get, "https://api.vk.com/method/getProfiles?access_token=TOKEN&fields=&scope=email&uids=1&v=5.71")
32
- .to_return(body: '{"response":[{"id":1}]}')
31
+ get_user = stub_request(
32
+ :get,
33
+ 'https://api.vk.com/method/getProfiles?access_token=TOKEN&fields=&scope=email&uids=1&v=5.71'
34
+ ).to_return(body: '{"response":[{"id":1}]}')
33
35
 
34
36
  token = provider.process_callback({ code: 'CODE' }, nil)
35
37
  provider.get_user_hash(token)
@@ -37,5 +39,4 @@ describe Sorcery::Providers::Vk do
37
39
  expect(get_user).to have_been_requested
38
40
  end
39
41
  end
40
-
41
42
  end
@@ -4,7 +4,12 @@ class SorceryController < ActionController::Base
4
4
  protect_from_forgery
5
5
 
6
6
  before_action :require_login_from_http_basic, only: [:test_http_basic_auth]
7
- before_action :require_login, only: [:test_logout, :test_logout_with_force_forget_me, :test_should_be_logged_in, :some_action]
7
+ before_action :require_login, only: %i[
8
+ test_logout
9
+ test_logout_with_force_forget_me
10
+ test_should_be_logged_in
11
+ some_action
12
+ ]
8
13
 
9
14
  def index; end
10
15
 
@@ -52,6 +57,11 @@ class SorceryController < ActionController::Base
52
57
  head :ok
53
58
  end
54
59
 
60
+ def test_invalidate_active_session
61
+ invalidate_active_sessions!
62
+ head :ok
63
+ end
64
+
55
65
  def test_login_with_remember
56
66
  @user = login(params[:email], params[:password])
57
67
  remember_me!
@@ -136,8 +146,16 @@ class SorceryController < ActionController::Base
136
146
  login_at(:facebook, state: 'bla')
137
147
  end
138
148
 
149
+ def login_at_test_instagram
150
+ login_at(:instagram)
151
+ end
152
+
153
+ def login_at_test_auth0
154
+ login_at(:auth0)
155
+ end
156
+
139
157
  def test_login_from_twitter
140
- if @user = login_from(:twitter)
158
+ if (@user = login_from(:twitter))
141
159
  redirect_to 'bla', notice: 'Success!'
142
160
  else
143
161
  redirect_to 'blu', alert: 'Failed!'
@@ -147,7 +165,7 @@ class SorceryController < ActionController::Base
147
165
  alias test_login_from test_login_from_twitter
148
166
 
149
167
  def test_login_from_facebook
150
- if @user = login_from(:facebook)
168
+ if (@user = login_from(:facebook))
151
169
  redirect_to 'bla', notice: 'Success!'
152
170
  else
153
171
  redirect_to 'blu', alert: 'Failed!'
@@ -155,7 +173,7 @@ class SorceryController < ActionController::Base
155
173
  end
156
174
 
157
175
  def test_login_from_github
158
- if @user = login_from(:github)
176
+ if (@user = login_from(:github))
159
177
  redirect_to 'bla', notice: 'Success!'
160
178
  else
161
179
  redirect_to 'blu', alert: 'Failed!'
@@ -163,7 +181,7 @@ class SorceryController < ActionController::Base
163
181
  end
164
182
 
165
183
  def test_login_from_paypal
166
- if @user = login_from(:paypal)
184
+ if (@user = login_from(:paypal))
167
185
  redirect_to 'bla', notice: 'Success!'
168
186
  else
169
187
  redirect_to 'blu', alert: 'Failed!'
@@ -171,7 +189,7 @@ class SorceryController < ActionController::Base
171
189
  end
172
190
 
173
191
  def test_login_from_wechat
174
- if @user = login_from(:wechat)
192
+ if (@user = login_from(:wechat))
175
193
  redirect_to 'bla', notice: 'Success!'
176
194
  else
177
195
  redirect_to 'blu', alert: 'Failed!'
@@ -179,7 +197,7 @@ class SorceryController < ActionController::Base
179
197
  end
180
198
 
181
199
  def test_login_from_microsoft
182
- if @user = login_from(:microsoft)
200
+ if (@user = login_from(:microsoft))
183
201
  redirect_to 'bla', notice: 'Success!'
184
202
  else
185
203
  redirect_to 'blu', alert: 'Failed!'
@@ -187,7 +205,7 @@ class SorceryController < ActionController::Base
187
205
  end
188
206
 
189
207
  def test_login_from_google
190
- if @user = login_from(:google)
208
+ if (@user = login_from(:google))
191
209
  redirect_to 'bla', notice: 'Success!'
192
210
  else
193
211
  redirect_to 'blu', alert: 'Failed!'
@@ -195,7 +213,7 @@ class SorceryController < ActionController::Base
195
213
  end
196
214
 
197
215
  def test_login_from_liveid
198
- if @user = login_from(:liveid)
216
+ if (@user = login_from(:liveid))
199
217
  redirect_to 'bla', notice: 'Success!'
200
218
  else
201
219
  redirect_to 'blu', alert: 'Failed!'
@@ -203,7 +221,7 @@ class SorceryController < ActionController::Base
203
221
  end
204
222
 
205
223
  def test_login_from_vk
206
- if @user = login_from(:vk)
224
+ if (@user = login_from(:vk))
207
225
  redirect_to 'bla', notice: 'Success!'
208
226
  else
209
227
  redirect_to 'blu', alert: 'Failed!'
@@ -211,7 +229,7 @@ class SorceryController < ActionController::Base
211
229
  end
212
230
 
213
231
  def test_login_from_jira
214
- if @user = login_from(:jira)
232
+ if (@user = login_from(:jira))
215
233
  redirect_to 'bla', notice: 'Success!'
216
234
  else
217
235
  redirect_to 'blu', alert: 'Failed!'
@@ -219,7 +237,7 @@ class SorceryController < ActionController::Base
219
237
  end
220
238
 
221
239
  def test_login_from_salesforce
222
- if @user = login_from(:salesforce)
240
+ if (@user = login_from(:salesforce))
223
241
  redirect_to 'bla', notice: 'Success!'
224
242
  else
225
243
  redirect_to 'blu', alert: 'Failed!'
@@ -227,7 +245,23 @@ class SorceryController < ActionController::Base
227
245
  end
228
246
 
229
247
  def test_login_from_slack
230
- if @user = login_from(:slack)
248
+ if (@user = login_from(:slack))
249
+ redirect_to 'bla', notice: 'Success!'
250
+ else
251
+ redirect_to 'blu', alert: 'Failed!'
252
+ end
253
+ end
254
+
255
+ def test_login_from_instagram
256
+ if (@user = login_from(:instagram))
257
+ redirect_to 'bla', notice: 'Success!'
258
+ else
259
+ redirect_to 'blu', alert: 'Failed!'
260
+ end
261
+ end
262
+
263
+ def test_login_from_auth0
264
+ if (@user = login_from(:auth0))
231
265
  redirect_to 'bla', notice: 'Success!'
232
266
  else
233
267
  redirect_to 'blu', alert: 'Failed!'
@@ -235,7 +269,7 @@ class SorceryController < ActionController::Base
235
269
  end
236
270
 
237
271
  def test_return_to_with_external_twitter
238
- if @user = login_from(:twitter)
272
+ if (@user = login_from(:twitter))
239
273
  redirect_back_or_to 'bla', notice: 'Success!'
240
274
  else
241
275
  redirect_to 'blu', alert: 'Failed!'
@@ -243,7 +277,7 @@ class SorceryController < ActionController::Base
243
277
  end
244
278
 
245
279
  def test_return_to_with_external_jira
246
- if @user = login_from(:jira)
280
+ if (@user = login_from(:jira))
247
281
  redirect_back_or_to 'bla', notice: 'Success!'
248
282
  else
249
283
  redirect_to 'blu', alert: 'Failed!'
@@ -253,7 +287,7 @@ class SorceryController < ActionController::Base
253
287
  alias test_return_to_with_external test_return_to_with_external_twitter
254
288
 
255
289
  def test_return_to_with_external_facebook
256
- if @user = login_from(:facebook)
290
+ if (@user = login_from(:facebook))
257
291
  redirect_back_or_to 'bla', notice: 'Success!'
258
292
  else
259
293
  redirect_to 'blu', alert: 'Failed!'
@@ -261,7 +295,7 @@ class SorceryController < ActionController::Base
261
295
  end
262
296
 
263
297
  def test_return_to_with_external_github
264
- if @user = login_from(:github)
298
+ if (@user = login_from(:github))
265
299
  redirect_back_or_to 'bla', notice: 'Success!'
266
300
  else
267
301
  redirect_to 'blu', alert: 'Failed!'
@@ -269,7 +303,7 @@ class SorceryController < ActionController::Base
269
303
  end
270
304
 
271
305
  def test_return_to_with_external_paypal
272
- if @user = login_from(:paypal)
306
+ if (@user = login_from(:paypal))
273
307
  redirect_back_or_to 'bla', notice: 'Success!'
274
308
  else
275
309
  redirect_to 'blu', alert: 'Failed!'
@@ -277,7 +311,7 @@ class SorceryController < ActionController::Base
277
311
  end
278
312
 
279
313
  def test_return_to_with_external_wechat
280
- if @user = login_from(:wechat)
314
+ if (@user = login_from(:wechat))
281
315
  redirect_back_or_to 'bla', notice: 'Success!'
282
316
  else
283
317
  redirect_to 'blu', alert: 'Failed!'
@@ -285,7 +319,7 @@ class SorceryController < ActionController::Base
285
319
  end
286
320
 
287
321
  def test_return_to_with_external_microsoft
288
- if @user = login_from(:microsoft)
322
+ if (@user = login_from(:microsoft))
289
323
  redirect_back_or_to 'bla', notice: 'Success!'
290
324
  else
291
325
  redirect_to 'blu', alert: 'Failed!'
@@ -293,7 +327,7 @@ class SorceryController < ActionController::Base
293
327
  end
294
328
 
295
329
  def test_return_to_with_external_google
296
- if @user = login_from(:google)
330
+ if (@user = login_from(:google))
297
331
  redirect_back_or_to 'bla', notice: 'Success!'
298
332
  else
299
333
  redirect_to 'blu', alert: 'Failed!'
@@ -301,7 +335,7 @@ class SorceryController < ActionController::Base
301
335
  end
302
336
 
303
337
  def test_return_to_with_external_liveid
304
- if @user = login_from(:liveid)
338
+ if (@user = login_from(:liveid))
305
339
  redirect_back_or_to 'bla', notice: 'Success!'
306
340
  else
307
341
  redirect_to 'blu', alert: 'Failed!'
@@ -309,7 +343,7 @@ class SorceryController < ActionController::Base
309
343
  end
310
344
 
311
345
  def test_return_to_with_external_vk
312
- if @user = login_from(:vk)
346
+ if (@user = login_from(:vk))
313
347
  redirect_back_or_to 'bla', notice: 'Success!'
314
348
  else
315
349
  redirect_to 'blu', alert: 'Failed!'
@@ -317,7 +351,7 @@ class SorceryController < ActionController::Base
317
351
  end
318
352
 
319
353
  def test_return_to_with_external_salesforce
320
- if @user = login_from(:salesforce)
354
+ if (@user = login_from(:salesforce))
321
355
  redirect_back_or_to 'bla', notice: 'Success!'
322
356
  else
323
357
  redirect_to 'blu', alert: 'Failed!'
@@ -325,7 +359,23 @@ class SorceryController < ActionController::Base
325
359
  end
326
360
 
327
361
  def test_return_to_with_external_slack
328
- if @user = login_from(:slack)
362
+ if (@user = login_from(:slack))
363
+ redirect_back_or_to 'bla', notice: 'Success!'
364
+ else
365
+ redirect_to 'blu', alert: 'Failed!'
366
+ end
367
+ end
368
+
369
+ def test_return_to_with_external_instagram
370
+ if (@user = login_from(:instagram))
371
+ redirect_back_or_to 'bla', notice: 'Success!'
372
+ else
373
+ redirect_to 'blu', alert: 'Failed!'
374
+ end
375
+ end
376
+
377
+ def test_return_to_with_external_auth0
378
+ if (@user = login_from(:auth0))
329
379
  redirect_back_or_to 'bla', notice: 'Success!'
330
380
  else
331
381
  redirect_to 'blu', alert: 'Failed!'
@@ -335,7 +385,7 @@ class SorceryController < ActionController::Base
335
385
  def test_create_from_provider
336
386
  provider = params[:provider]
337
387
  login_from(provider)
338
- if @user = create_from(provider)
388
+ if (@user = create_from(provider))
339
389
  redirect_to 'bla', notice: 'Success!'
340
390
  else
341
391
  redirect_to 'blu', alert: 'Failed!'
@@ -344,12 +394,13 @@ class SorceryController < ActionController::Base
344
394
 
345
395
  def test_add_second_provider
346
396
  provider = params[:provider]
347
- if logged_in?
348
- if @user = add_provider_to_user(provider)
349
- redirect_to 'bla', notice: 'Success!'
350
- else
351
- redirect_to 'blu', alert: 'Failed!'
352
- end
397
+
398
+ return unless logged_in?
399
+
400
+ if (@user = add_provider_to_user(provider))
401
+ redirect_to 'bla', notice: 'Success!'
402
+ else
403
+ redirect_to 'blu', alert: 'Failed!'
353
404
  end
354
405
  end
355
406