Skip to content

Commit

Permalink
Merge pull request #869 from CHSS-IT/fix_local_logout_routing
Browse files Browse the repository at this point in the history
Fix local logout routing
  • Loading branch information
CraigJZ committed Jun 18, 2024
2 parents a30804f + 00ebc2b commit cbd8711
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def end_session
redirect_to '/logout'
end

def destroy
redirect_to root_path, notice: t(".success")
end

private

def find_user
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ en:
settings:
update:
success: 'Setting was successfully updated.'
sessions:
destroy:
success: 'You have logged out successfully.'
users:
create:
success: 'User was successfully created'
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@
get '/login', to: 'sections#index'

get 'exit', to: 'sessions#end_session', as: :logout

get '/logout', to: 'sessions#destroy'
end
5 changes: 5 additions & 0 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
get logout_url
assert_in_delta @user.reload.updated_at, old_updated_at, 1.second
end

test 'destroy action redirects to the root path' do
get '/logout'
assert_redirected_to root_path
end
end

0 comments on commit cbd8711

Please sign in to comment.