Commit 8c6a28dd5beff52cec5f41eac0c1db2aef5d4992
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge remote-tracking branch 'origin/production' into translate
Showing
3 changed files
with
8 additions
and
5 deletions
Show diff stats
lib/noosfero/api/helpers.rb
| @@ -273,7 +273,7 @@ require 'grape' | @@ -273,7 +273,7 @@ require 'grape' | ||
| 273 | if javascript_console_message.present? | 273 | if javascript_console_message.present? |
| 274 | error!(message_hash, status) | 274 | error!(message_hash, status) |
| 275 | else | 275 | else |
| 276 | - error!(user_message, status) | 276 | + error!({'message' => user_message, :code => status}, status) |
| 277 | end | 277 | end |
| 278 | end | 278 | end |
| 279 | 279 |
lib/noosfero/api/session.rb
| @@ -38,8 +38,8 @@ module Noosfero | @@ -38,8 +38,8 @@ module Noosfero | ||
| 38 | post "/register" do | 38 | post "/register" do |
| 39 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields | 39 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields |
| 40 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 40 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 41 | - # test_captcha will render_api_error! and exit in case of some problem | ||
| 42 | - # this return is only improve the clarity of the execution path | 41 | + # test_captcha will render_api_error! and exit in case of any problem |
| 42 | + # this return is just to improve the clarity of the execution path | ||
| 43 | return unless test_captcha(remote_ip, params, environment) | 43 | return unless test_captcha(remote_ip, params, environment) |
| 44 | user = User.new(attrs) | 44 | user = User.new(attrs) |
| 45 | if user.save | 45 | if user.save |
| @@ -96,7 +96,10 @@ module Noosfero | @@ -96,7 +96,10 @@ module Noosfero | ||
| 96 | post "/forgot_password" do | 96 | post "/forgot_password" do |
| 97 | requestors = fetch_requestors(params[:value]) | 97 | requestors = fetch_requestors(params[:value]) |
| 98 | not_found! if requestors.blank? | 98 | not_found! if requestors.blank? |
| 99 | - | 99 | + remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 100 | + # test_captcha will render_api_error! and exit in case of any problem | ||
| 101 | + # this return is just to improve the clarity of the execution path | ||
| 102 | + return unless test_captcha(remote_ip, params, environment) | ||
| 100 | requestors.each do |requestor| | 103 | requestors.each do |requestor| |
| 101 | ChangePassword.create!(:requestor => requestor) | 104 | ChangePassword.create!(:requestor => requestor) |
| 102 | end | 105 | end |
test/unit/api/users_test.rb
| @@ -29,7 +29,7 @@ class UsersTest < ActiveSupport::TestCase | @@ -29,7 +29,7 @@ class UsersTest < ActiveSupport::TestCase | ||
| 29 | params[:user] = {:login => 'some', :password => '123456', :password_confirmation => '123456', :email => 'some@some.com'} | 29 | params[:user] = {:login => 'some', :password => '123456', :password_confirmation => '123456', :email => 'some@some.com'} |
| 30 | post "/api/v1/users?#{params.to_query}" | 30 | post "/api/v1/users?#{params.to_query}" |
| 31 | json = JSON.parse(last_response.body) | 31 | json = JSON.parse(last_response.body) |
| 32 | - assert_equal 'Username / Email já está em uso,e-Mail já está em uso', json['error'] | 32 | + assert_equal 'Username / Email já está em uso,e-Mail já está em uso', json['message'] |
| 33 | end | 33 | end |
| 34 | 34 | ||
| 35 | should 'return 400 status for invalid user creation' do | 35 | should 'return 400 status for invalid user creation' do |