Commit f092d7d1895ce53852ab7153a9e15874e547bd5c
1 parent
7924652d
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
changes on api and oauth_client plugin to allow signup through api
Showing
4 changed files
with
9 additions
and
6 deletions
Show diff stats
lib/noosfero/api/api.rb
lib/noosfero/api/helpers.rb
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | def set_locale |
11 | 11 | I18n.locale = (params[:lang] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en') |
12 | 12 | end |
13 | - | |
13 | + | |
14 | 14 | def current_user |
15 | 15 | private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s |
16 | 16 | @current_user ||= User.find_by_private_token(private_token) |
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | |
58 | 58 | def find_article(articles, id) |
59 | 59 | article = articles.find(id) |
60 | - article.display_to?(current_user.person) ? article : forbidden! | |
60 | + article.display_to?(current_user) ? article : forbidden! | |
61 | 61 | end |
62 | 62 | |
63 | 63 | def post_article(asset, params) | ... | ... |
plugins/oauth_client/controllers/public/oauth_client_plugin_public_controller.rb
... | ... | @@ -22,7 +22,7 @@ class OauthClientPluginPublicController < PublicController |
22 | 22 | if session.delete(:oauth_client_popup) || params[:oauth_client_popup] |
23 | 23 | current_user.private_token_expired? if current_user.present? |
24 | 24 | private_token = current_user.present? ? current_user.private_token : '' |
25 | - render 'oauth_client_plugin_public/finish', :locals => {:private_token => private_token, :user => current_user}, :layout => false | |
25 | + render 'oauth_client_plugin_public/finish', :locals => {:private_token => private_token}, :layout => false | |
26 | 26 | else |
27 | 27 | redirect_to :controller => :home |
28 | 28 | end | ... | ... |
plugins/oauth_client/lib/oauth_client_plugin.rb
... | ... | @@ -84,8 +84,11 @@ class OauthClientPlugin < Noosfero::Plugin |
84 | 84 | |
85 | 85 | if auth.present? && params[:user].present? |
86 | 86 | params[:user][:oauth_providers] = [OauthClientPlugin::Provider.find(session[:provider_id])] |
87 | + | |
87 | 88 | if request.post? && auth.info.email != params[:user][:email] |
88 | - raise "Wrong email for oauth signup" | |
89 | + unless params[:user][:email].blank? | |
90 | + raise "Wrong email for oauth signup. EMAIL: #{params[:user][:email]}" | |
91 | + end | |
89 | 92 | end |
90 | 93 | end |
91 | 94 | } | ... | ... |