Skip to content

Conversation

@Gabe-Torres
Copy link
Contributor

Resolves #5101

Description

Adds the ability for users to sign out from error pages (403, 404, 422, 500)

  • Add GET route for sign out in devise_scope block in routes
  • Add sign_out_error_page method to sessions controller
  • Add feature tests for logout on error pages
  • Remove data-method="delete" from error pages

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Added feature tests that verify users can log out from all error pages
  • Tests check that the logout link is present and that clicking it successfully logs the user out

log in as org_admin1@example.com
then go to http://localhost:3000/500
click on "Log out"

Screenshots

404 error page

404_html_after

422 error page

422_html_after

403 error page

403_html_after

500 error page

500_html_after

@cielf
Copy link
Collaborator

cielf commented May 9, 2025

LGTM functionally. over to @dorner for technical review, though I do note that the linter failed

@cielf cielf requested a review from dorner May 9, 2025 23:42
@Gabe-Torres
Copy link
Contributor Author

LGTM functionally. over to @dorner for technical review, though I do note that the linter failed

Could it be because my branch is not up to date with main?

@cielf
Copy link
Collaborator

cielf commented May 11, 2025

Maybe? I think I've seen some folk talking about some rubocop weirdness since the update to 3.4 on the slack.

@cielf
Copy link
Collaborator

cielf commented May 25, 2025

Sorry @Gabe-Torres -- I thought you were going to do the merge of main into your branch! Have done it, and the linter is now passing.

@dorner -- Can you do the technical pass on this, please? Thanks!

@Gabe-Torres
Copy link
Contributor Author

Sorry @Gabe-Torres -- I thought you were going to do the merge of main into your branch! Have done it, and the linter is now passing.

@dorner -- Can you do the technical pass on this, please? Thanks!

I thought we were waiting for the code approval before the merge of main. Sorry about that! Thanks @cielf !

@cielf
Copy link
Collaborator

cielf commented May 27, 2025

@Gabe-Torres We wait for code approval for merge of your branch into main. We can merge the current main into your branch whenever.

- Add GET route for sign out in devise_scope block in routes
- Add sign_out action to sessions controller
- Add feature tests for logout on error pages
- Remove data-method="delete" from error pages
- Rename sign_out method to sign_out_error_page in sessions controller
- Update route to use new method name
@Gabe-Torres Gabe-Torres force-pushed the 5101_static_error_pages branch from b68702d to a7522b6 Compare May 31, 2025 02:02
@cielf
Copy link
Collaborator

cielf commented Jun 9, 2025

I think this is in @dorner's hands for review later this week.

end

# GET /resource/sign_out
def sign_out_error_page
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused... doesn't Devise already generate a sign_out route? Is there a reason you can't reuse that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the custom route is that the static error pages (403, 404, 422, 500) are served as plain HTML files and can only make GET requests. Devise's standard sign-out route requires a DELETE request. I believe another way to reuse Devise's included sign-out is to make JavaScript scripts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree and confirm -- upsettingly devise does use the DELETE which is actually sent as a POST with a method. The other way to do this would be to make them form submits, but that seems wrong also. I like it this way as a new endpoint.

@cielf
Copy link
Collaborator

cielf commented Jul 3, 2025

@Gabe-Torres -- Are you still working on this?

@Gabe-Torres
Copy link
Contributor Author

Sorry for the super delayed response y'all! I recently started a new position and got a bit busy

@awwaiid
Copy link
Collaborator

awwaiid commented Aug 17, 2025

... buuuut the tests fail :)

@awwaiid
Copy link
Collaborator

awwaiid commented Aug 24, 2025

Ok PIVOT! Let's switch to using a form-button for the logout so that it can send a POST+DELETE without needing javascript. Let me know if that makes sense or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error on logging out on static error pages

4 participants