Commit 9176e687f464b1b7ef28d756b646ddf445e7c962
1 parent
307ad8fb
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
oauth_client: generate private token when login
Showing
2 changed files
with
12 additions
and
0 deletions
Show diff stats
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
@@ -36,6 +36,7 @@ class OauthClientPluginPublicController < PublicController | @@ -36,6 +36,7 @@ class OauthClientPluginPublicController < PublicController | ||
36 | auth ||= person.oauth_auths.create! profile: person, provider: provider, enabled: true | 36 | auth ||= person.oauth_auths.create! profile: person, provider: provider, enabled: true |
37 | if auth.enabled? && provider.enabled? | 37 | if auth.enabled? && provider.enabled? |
38 | self.current_user = person.user | 38 | self.current_user = person.user |
39 | + self.current_user.generate_private_token! | ||
39 | else | 40 | else |
40 | session[:notice] = _("Can't login with %s") % provider.name | 41 | session[:notice] = _("Can't login with %s") % provider.name |
41 | end | 42 | end |
plugins/oauth_client/test/functional/oauth_client_plugin_public_controller_test.rb
@@ -31,6 +31,17 @@ class OauthClientPluginPublicControllerTest < ActionController::TestCase | @@ -31,6 +31,17 @@ class OauthClientPluginPublicControllerTest < ActionController::TestCase | ||
31 | assert_equal user.id, session[:user] | 31 | assert_equal user.id, session[:user] |
32 | end | 32 | end |
33 | 33 | ||
34 | + should 'generate private token when login' do | ||
35 | + user = create_user | ||
36 | + auth.info.stubs(:email).returns(user.email) | ||
37 | + auth.info.stubs(:name).returns(user.name) | ||
38 | + session[:provider_id] = provider.id | ||
39 | + | ||
40 | + assert user.reload.private_token.nil? | ||
41 | + get :callback | ||
42 | + assert user.reload.private_token.present? | ||
43 | + end | ||
44 | + | ||
34 | should 'do not login when the provider is disabled' do | 45 | should 'do not login when the provider is disabled' do |
35 | user = create_user | 46 | user = create_user |
36 | auth.info.stubs(:email).returns(user.email) | 47 | auth.info.stubs(:email).returns(user.email) |