Commit 06bd6b59d3c92b17d80cea03012b763d0683860a
1 parent
8d285aca
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
oauth_client: receive parameter for popup login
Showing
3 changed files
with
15 additions
and
12 deletions
Show diff stats
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
| ... | ... | @@ -18,6 +18,16 @@ class OauthClientPluginPublicController < PublicController |
| 18 | 18 | redirect_to root_url |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | + def finish | |
| 22 | + if logged_in? && session.delete(:oauth_client_popup) | |
| 23 | + current_user.private_token_expired? if current_user.present? | |
| 24 | + private_token = current_user.present? ? current_user.private_token : '' | |
| 25 | + render 'oauth_client_plugin_public/finish', :locals => {:private_token => private_token} | |
| 26 | + else | |
| 27 | + redirect_to :controller => :home | |
| 28 | + end | |
| 29 | + end | |
| 30 | + | |
| 21 | 31 | protected |
| 22 | 32 | |
| 23 | 33 | def login(user) |
| ... | ... | @@ -31,8 +41,8 @@ class OauthClientPluginPublicController < PublicController |
| 31 | 41 | else |
| 32 | 42 | session[:notice] = _("Can't login with #{provider.name}") |
| 33 | 43 | end |
| 34 | - session[:oauth_client_login] = true | |
| 35 | - session[:return_to] = '/' | |
| 44 | + session[:oauth_client_popup] = true if request.env["omniauth.params"]['oauth_client_popup'] | |
| 45 | + session[:return_to] = url_for(:controller => :oauth_client_plugin_public, :action => :finish) | |
| 36 | 46 | |
| 37 | 47 | redirect_to :controller => :account, :action => :login |
| 38 | 48 | end |
| ... | ... | @@ -40,8 +50,8 @@ class OauthClientPluginPublicController < PublicController |
| 40 | 50 | def signup(auth) |
| 41 | 51 | login = auth.info.email.split('@').first |
| 42 | 52 | session[:oauth_data] = auth |
| 43 | - session[:oauth_client_login] = true | |
| 44 | - session[:return_to] = '/' | |
| 53 | + session[:oauth_client_popup] = true if request.env["omniauth.params"]['oauth_client_popup'] | |
| 54 | + session[:return_to] = url_for(:controller => :oauth_client_plugin_public, :action => :finish) | |
| 45 | 55 | name = auth.info.name |
| 46 | 56 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' |
| 47 | 57 | 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
| ... | ... | @@ -29,14 +29,6 @@ class OauthClientPlugin < Noosfero::Plugin |
| 29 | 29 | end |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | - def body_ending | |
| 33 | - if logged_in? && session.delete(:oauth_client_login) | |
| 34 | - current_user.private_token_expired? if current_user.present? | |
| 35 | - private_token = current_user.present? ? current_user.private_token : '' | |
| 36 | - "<script>oauthPluginCloseLoginPopup(#{logged_in?}, '#{private_token}');</script>" | |
| 37 | - end | |
| 38 | - end | |
| 39 | - | |
| 40 | 32 | def js_files |
| 41 | 33 | 'main.js' |
| 42 | 34 | end | ... | ... |
plugins/oauth_client/views/oauth_client_plugin_public/finish.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<script>oauthPluginCloseLoginPopup(<%= logged_in? %>, '<%= private_token %>');</script> | ... | ... |