Commit d35f1b22c7868d66ed444a400ceb51e6e6d1bd16
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'proposal-login' into stable
Showing
3 changed files
with
25 additions
and
0 deletions
Show diff stats
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
| ... | ... | @@ -31,6 +31,8 @@ class OauthClientPluginPublicController < PublicController |
| 31 | 31 | else |
| 32 | 32 | session[:notice] = _("Can't login with #{provider.name}") |
| 33 | 33 | end |
| 34 | + session[:oauth_client_login] = true | |
| 35 | + session[:return_to] = '/' | |
| 34 | 36 | |
| 35 | 37 | redirect_to :controller => :account, :action => :login |
| 36 | 38 | end |
| ... | ... | @@ -38,6 +40,8 @@ class OauthClientPluginPublicController < PublicController |
| 38 | 40 | def signup(auth) |
| 39 | 41 | login = auth.info.email.split('@').first |
| 40 | 42 | session[:oauth_data] = auth |
| 43 | + session[:oauth_client_login] = true | |
| 44 | + session[:return_to] = '/' | |
| 41 | 45 | name = auth.info.name |
| 42 | 46 | name ||= auth.extra && auth.extra.raw_info ? auth.extra.raw_info.name : '' |
| 43 | 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
| ... | ... | @@ -29,6 +29,18 @@ 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 | + def js_files | |
| 41 | + 'main.js' | |
| 42 | + end | |
| 43 | + | |
| 32 | 44 | PROVIDERS = { |
| 33 | 45 | :facebook => { |
| 34 | 46 | :name => 'Facebook' | ... | ... |
| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | +function oauthPluginCloseLoginPopup(loggedIn, privateToken) { | |
| 2 | + if (window.opener && typeof window.opener.oauthPluginHandleLoginResult == 'function') { | |
| 3 | + try { | |
| 4 | + window.opener.oauthPluginHandleLoginResult(loggedIn, privateToken); | |
| 5 | + } catch (err) {} | |
| 6 | + window.close(); | |
| 7 | + } | |
| 8 | + return false; | |
| 9 | +} | ... | ... |