Commit 8d285aca7b044df11bcc8ee657769e3599f0f020
1 parent
2614a772
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
oauth_client: force return to home
Showing
2 changed files
with
4 additions
and
1 deletions
Show diff stats
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
| @@ -32,6 +32,7 @@ class OauthClientPluginPublicController < PublicController | @@ -32,6 +32,7 @@ class OauthClientPluginPublicController < PublicController | ||
| 32 | session[:notice] = _("Can't login with #{provider.name}") | 32 | session[:notice] = _("Can't login with #{provider.name}") |
| 33 | end | 33 | end |
| 34 | session[:oauth_client_login] = true | 34 | session[:oauth_client_login] = true |
| 35 | + session[:return_to] = '/' | ||
| 35 | 36 | ||
| 36 | redirect_to :controller => :account, :action => :login | 37 | redirect_to :controller => :account, :action => :login |
| 37 | end | 38 | end |
| @@ -39,6 +40,8 @@ class OauthClientPluginPublicController < PublicController | @@ -39,6 +40,8 @@ class OauthClientPluginPublicController < PublicController | ||
| 39 | def signup(auth) | 40 | def signup(auth) |
| 40 | login = auth.info.email.split('@').first | 41 | login = auth.info.email.split('@').first |
| 41 | session[:oauth_data] = auth | 42 | session[:oauth_data] = auth |
| 43 | + session[:oauth_client_login] = true | ||
| 44 | + session[:return_to] = '/' | ||
| 42 | name = auth.info.name | 45 | name = auth.info.name |
| 43 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' | 46 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' |
| 44 | redirect_to :controller => :account, :action => :signup, :user => {:login => login, :email => auth.info.email}, :profile_data => {:name => name} | 47 | redirect_to :controller => :account, :action => :signup, :user => {:login => login, :email => auth.info.email}, :profile_data => {:name => name} |
plugins/oauth_client/lib/oauth_client_plugin.rb
| @@ -30,7 +30,7 @@ class OauthClientPlugin < Noosfero::Plugin | @@ -30,7 +30,7 @@ class OauthClientPlugin < Noosfero::Plugin | ||
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | def body_ending | 32 | def body_ending |
| 33 | - if session.delete(:oauth_client_login) | 33 | + if logged_in? && session.delete(:oauth_client_login) |
| 34 | current_user.private_token_expired? if current_user.present? | 34 | current_user.private_token_expired? if current_user.present? |
| 35 | private_token = current_user.present? ? current_user.private_token : '' | 35 | private_token = current_user.present? ? current_user.private_token : '' |
| 36 | "<script>oauthPluginCloseLoginPopup(#{logged_in?}, '#{private_token}');</script>" | 36 | "<script>oauthPluginCloseLoginPopup(#{logged_in?}, '#{private_token}');</script>" |