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 | 36 | auth ||= person.oauth_auths.create! profile: person, provider: provider, enabled: true |
37 | 37 | if auth.enabled? && provider.enabled? |
38 | 38 | self.current_user = person.user |
39 | + self.current_user.generate_private_token! | |
39 | 40 | else |
40 | 41 | session[:notice] = _("Can't login with %s") % provider.name |
41 | 42 | end | ... | ... |
plugins/oauth_client/test/functional/oauth_client_plugin_public_controller_test.rb
... | ... | @@ -31,6 +31,17 @@ class OauthClientPluginPublicControllerTest < ActionController::TestCase |
31 | 31 | assert_equal user.id, session[:user] |
32 | 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 | 45 | should 'do not login when the provider is disabled' do |
35 | 46 | user = create_user |
36 | 47 | auth.info.stubs(:email).returns(user.email) | ... | ... |