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,6 +18,16 @@ class OauthClientPluginPublicController < PublicController | ||
18 | redirect_to root_url | 18 | redirect_to root_url |
19 | end | 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 | protected | 31 | protected |
22 | 32 | ||
23 | def login(user) | 33 | def login(user) |
@@ -31,8 +41,8 @@ class OauthClientPluginPublicController < PublicController | @@ -31,8 +41,8 @@ class OauthClientPluginPublicController < PublicController | ||
31 | else | 41 | else |
32 | session[:notice] = _("Can't login with #{provider.name}") | 42 | session[:notice] = _("Can't login with #{provider.name}") |
33 | end | 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 | redirect_to :controller => :account, :action => :login | 47 | redirect_to :controller => :account, :action => :login |
38 | end | 48 | end |
@@ -40,8 +50,8 @@ class OauthClientPluginPublicController < PublicController | @@ -40,8 +50,8 @@ class OauthClientPluginPublicController < PublicController | ||
40 | def signup(auth) | 50 | def signup(auth) |
41 | login = auth.info.email.split('@').first | 51 | login = auth.info.email.split('@').first |
42 | session[:oauth_data] = auth | 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 | name = auth.info.name | 55 | name = auth.info.name |
46 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' | 56 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' |
47 | redirect_to :controller => :account, :action => :signup, :user => {:login => login, :email => auth.info.email}, :profile_data => {:name => name} | 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,14 +29,6 @@ class OauthClientPlugin < Noosfero::Plugin | ||
29 | end | 29 | end |
30 | end | 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 | def js_files | 32 | def js_files |
41 | 'main.js' | 33 | 'main.js' |
42 | end | 34 | end |
plugins/oauth_client/views/oauth_client_plugin_public/finish.html.erb
0 → 100644
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<script>oauthPluginCloseLoginPopup(<%= logged_in? %>, '<%= private_token %>');</script> |