Commit 7a4a799783e04ea7af5efbee03d18510a9baa39b
Exists in
staging
and in
4 other branches
Merge branch 'api' into production
Showing
3 changed files
with
18 additions
and
7 deletions
Show diff stats
lib/noosfero/api/api.rb
... | ... | @@ -6,7 +6,15 @@ module Noosfero |
6 | 6 | module API |
7 | 7 | class API < Grape::API |
8 | 8 | use Rack::JSONP |
9 | - | |
9 | + | |
10 | + logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log")) | |
11 | + logger.formatter = GrapeLogging::Formatters::Default.new | |
12 | + use RequestLogger, { logger: logger } | |
13 | + | |
14 | + rescue_from :all do |e| | |
15 | + logger.error e | |
16 | + end | |
17 | + | |
10 | 18 | @@NOOSFERO_CONF = nil |
11 | 19 | |
12 | 20 | def self.NOOSFERO_CONF | ... | ... |
lib/noosfero/api/request_logger.rb
lib/noosfero/api/session.rb
... | ... | @@ -39,12 +39,16 @@ module Noosfero |
39 | 39 | unique_attributes! User, [:email, :login] |
40 | 40 | attrs = attributes_for_keys [:email, :login, :password] |
41 | 41 | attrs[:password_confirmation] = attrs[:password] |
42 | - remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | |
43 | - private_key = API.NOOSFERO_CONF['api_recaptcha_private_key'] | |
44 | - api_recaptcha_verify_uri = API.NOOSFERO_CONF['api_recaptcha_verify_uri'] | |
45 | - captcha_result = verify_recaptcha_v2(remote_ip, params['g-recaptcha-response'], private_key, api_recaptcha_verify_uri) | |
42 | + | |
43 | + #Commented for stress tests | |
44 | + | |
45 | + # remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | |
46 | + # private_key = API.NOOSFERO_CONF['api_recaptcha_private_key'] | |
47 | + # api_recaptcha_verify_uri = API.NOOSFERO_CONF['api_recaptcha_verify_uri'] | |
48 | + # captcha_result = verify_recaptcha_v2(remote_ip, params['g-recaptcha-response'], private_key, api_recaptcha_verify_uri) | |
46 | 49 | user = User.new(attrs) |
47 | - if captcha_result["success"] and user.save! | |
50 | +# if captcha_result["success"] and user.save | |
51 | + if user.save | |
48 | 52 | user.activate |
49 | 53 | user.generate_private_token! |
50 | 54 | present user, :with => Entities::UserLogin | ... | ... |