From 27a8e0fbca12cf203a773c6f4a3f8ea07182f75d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 10 Oct 2015 12:27:19 +0200 Subject: [PATCH 1/2] Test if user is nil in #reset_authentication_token Actually it redirects to stream page and says that user is already logged in. Fix https://github.com/diaspora/diaspora/issues/6326 --- app/controllers/sessions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 05016d2a7..61f464209 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,6 +7,6 @@ class SessionsController < Devise::SessionsController before_filter :reset_authentication_token, :only => [:destroy] def reset_authentication_token - current_user.reset_authentication_token! + current_user.reset_authentication_token! unless current_user.nil? end end From 374679c0937d594aa1c18d6e3641b3541a9c4597 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sat, 20 Feb 2016 23:48:05 +0100 Subject: [PATCH 2/2] Add rspec test for reset_authentication_token without current_user closes #6707 --- Changelog.md | 3 ++- spec/controllers/sessions_controller_spec.rb | 22 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index ece019c6c..84e64e77c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,7 +3,8 @@ ## Refactor ## Bug fixes -* Fix empty name field when editing aspect names [#6548](https://github.com/diaspora/diaspora/issues/6548) +* Fix empty name field when editing aspect names [#6706](https://github.com/diaspora/diaspora/pull/6706) +* Fix internal server error when trying to log out of an expired session [#6707](https://github.com/diaspora/diaspora/pull/6707) ## Features diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 5b802635c..4ba846ed1 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -47,4 +47,26 @@ describe SessionsController, type: :controller do expect(response).to redirect_to root_path end end + + describe "#reset_authentication_token" do + context "for a logged in user" do + before do + sign_in :user, @user + end + + it "succeeds" do + expect { @controller.send(:reset_authentication_token) }.to_not raise_error + end + end + + context "for a logged out user" do + before do + sign_out :user + end + + it "succeeds" do + expect { @controller.send(:reset_authentication_token) }.to_not raise_error + end + end + end end