[Git][noosfero/noosfero][master] 2 commits: should not raise on logout if there is no user
Leandro Nunes
gitlab at mg.gitlab.com
Wed May 9 17:19:43 BRT 2018
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
72e467e0 by Leandro Nunes dos Santos at 2018-05-09T16:51:20Z
should not raise on logout if there is no user
- - - - -
bc6473a5 by Leandro Nunes at 2018-05-09T20:19:33Z
Merge branch 'reset-api-session-without-user' into 'master'
should not raise on logout if there is no user
See merge request noosfero/noosfero!1471
- - - - -
2 changed files:
- app/api/v1/session.rb
- test/api/session_test.rb
Changes:
=====================================
app/api/v1/session.rb
=====================================
--- a/app/api/v1/session.rb
+++ b/app/api/v1/session.rb
@@ -33,8 +33,10 @@ module Api
# Example Request:
# POST http://localhost:3000/api/v1/logout
post "/logout" do
- current_user.forget_me
- current_user.update({:chat_status_at => DateTime.now}.merge({:last_chat_status => current_user.chat_status, :chat_status => 'offline'}))
+ if current_user
+ current_user.forget_me
+ current_user.update({:chat_status_at => DateTime.now}.merge({:last_chat_status => current_user.chat_status, :chat_status => 'offline'}))
+ end
reset_session
output = {:success => true}
output[:message] = _('Logout successfully.')
=====================================
test/api/session_test.rb
=====================================
--- a/test/api/session_test.rb
+++ b/test/api/session_test.rb
@@ -7,6 +7,14 @@ class SessionTest < ActiveSupport::TestCase
login_api
end
+ should 'should reset session on logout without current_user' do
+ logout_api
+ post "/api/v1/logout?#{params.to_query}"
+
+ json = JSON.parse(last_response.body)
+ assert_equal json["code"], Api::Status::LOGOUT
+ end
+
should 'generate private token when login' do
params = {:login => "testapi", :password => "testapi"}
post "/api/v1/login?#{params.to_query}"
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/d87f3a5a1ea604c36d52ebe5d05dc05782d3a023...bc6473a5e83b660eeed47a8b52c5b44be854304d
--
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/d87f3a5a1ea604c36d52ebe5d05dc05782d3a023...bc6473a5e83b660eeed47a8b52c5b44be854304d
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180509/f5a48616/attachment-0001.html>
More information about the Noosfero-dev
mailing list