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
@@ -12,8 +12,8 @@ module Noosfero | @@ -12,8 +12,8 @@ module Noosfero | ||
12 | use GrapeLogging::Middleware::RequestLogger, { logger: logger } | 12 | use GrapeLogging::Middleware::RequestLogger, { logger: logger } |
13 | 13 | ||
14 | rescue_from :all do |e| | 14 | rescue_from :all do |e| |
15 | - #puts e.inspect | ||
16 | - #puts e.backtrace.inspect | 15 | + puts e.inspect |
16 | + puts e.backtrace.inspect | ||
17 | #logger.error e | 17 | #logger.error e |
18 | end | 18 | end |
19 | 19 |
lib/noosfero/api/helpers.rb
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | def set_locale | 10 | def set_locale |
11 | I18n.locale = (params[:lang] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en') | 11 | I18n.locale = (params[:lang] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en') |
12 | end | 12 | end |
13 | - | 13 | + |
14 | def current_user | 14 | def current_user |
15 | private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s | 15 | private_token = (params[PRIVATE_TOKEN_PARAM] || headers['Private-Token']).to_s |
16 | @current_user ||= User.find_by_private_token(private_token) | 16 | @current_user ||= User.find_by_private_token(private_token) |
@@ -57,7 +57,7 @@ | @@ -57,7 +57,7 @@ | ||
57 | 57 | ||
58 | def find_article(articles, id) | 58 | def find_article(articles, id) |
59 | article = articles.find(id) | 59 | article = articles.find(id) |
60 | - article.display_to?(current_user.person) ? article : forbidden! | 60 | + article.display_to?(current_user) ? article : forbidden! |
61 | end | 61 | end |
62 | 62 | ||
63 | def post_article(asset, params) | 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,7 +22,7 @@ class OauthClientPluginPublicController < PublicController | ||
22 | if session.delete(:oauth_client_popup) || params[:oauth_client_popup] | 22 | if session.delete(:oauth_client_popup) || params[:oauth_client_popup] |
23 | current_user.private_token_expired? if current_user.present? | 23 | current_user.private_token_expired? if current_user.present? |
24 | private_token = current_user.present? ? current_user.private_token : '' | 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 | else | 26 | else |
27 | redirect_to :controller => :home | 27 | redirect_to :controller => :home |
28 | end | 28 | end |
plugins/oauth_client/lib/oauth_client_plugin.rb
@@ -84,8 +84,11 @@ class OauthClientPlugin < Noosfero::Plugin | @@ -84,8 +84,11 @@ class OauthClientPlugin < Noosfero::Plugin | ||
84 | 84 | ||
85 | if auth.present? && params[:user].present? | 85 | if auth.present? && params[:user].present? |
86 | params[:user][:oauth_providers] = [OauthClientPlugin::Provider.find(session[:provider_id])] | 86 | params[:user][:oauth_providers] = [OauthClientPlugin::Provider.find(session[:provider_id])] |
87 | + | ||
87 | if request.post? && auth.info.email != params[:user][:email] | 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 | end | 92 | end |
90 | end | 93 | end |
91 | } | 94 | } |