Commit ef5d596c93cdcf212db043b0404ae7bd0141971f
1 parent
64134001
Fixes logout bug
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Dylan Guedes <djmgguedes@gmail.com>
Showing
2 changed files
with
20 additions
and
1 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -154,7 +154,7 @@ class AccountController < ApplicationController |
154 | 154 | |
155 | 155 | # action to perform logout from the application |
156 | 156 | def logout |
157 | - if logged_in? | |
157 | + if logged_in? && self.current_user.id.present? | |
158 | 158 | self.current_user.forget_me |
159 | 159 | end |
160 | 160 | reset_session | ... | ... |
plugins/oauth_client/test/functional/account_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,19 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +class AccountControllerTest < ActionController::TestCase | |
4 | + def setup | |
5 | + external_person = ExternalPerson.create!(identifier: 'johnlock', | |
6 | + name: 'John Locke', | |
7 | + source: 'anerenvironment.org', | |
8 | + email: 'john@locke.org', | |
9 | + created_at: Date.yesterday | |
10 | + ) | |
11 | + session[:external] = external_person.id | |
12 | + end | |
13 | + | |
14 | + should "not create an User when logging out" do | |
15 | + assert_no_difference 'User.count' do | |
16 | + get :logout | |
17 | + end | |
18 | + end | |
19 | +end | ... | ... |