Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use POST method instead of GET to perform logout in browsable API#9208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
auvipy merged 2 commits intoencode:masterfromrealsuayip:add_opt_logout_form
Feb 19, 2024

Conversation

@realsuayip
Copy link
Contributor

Description

Fixes#9206

jathanism and shuuji3 reacted with thumbs up emoji
@auvipyauvipy self-requested a reviewJanuary 4, 2024 13:58
<input type="hidden" name="csrfmiddlewaretoken" value="{csrf_token}">
</form>
<li>
<a href="#" onclick='document.getElementById("logoutForm").submit()'>Log out</a>
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure, but should this href use #?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Since it immediately redirects the user tonext, it should not be a problem?

Alternatives:

  • We could remove the href. In that case, we would need to add inline css so that cursor would be pointer. Also we'll probably need to addrole="button" for improved semantics for screen readers.

  • We could setnext as href. Although I'm not sure how it would behave. We may need to callpreventDefault.

I'm refraining from using<button> here since it would require a bit of CSS juggling.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a pretty standard pattern I think, seems okay to me.

auvipy reacted with thumbs up emoji
@lovelydinosaurlovelydinosaur mentioned this pull requestJan 4, 2024
@auvipyauvipy added this to the3.15 milestoneJan 11, 2024
</li>"""
snippet=format_html(snippet,user=escape(user),href=logout_url,next=escape(request.path))

snippet=format_html(snippet,user=escape(user),href=logout_url,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to update the tests a bit to verify it is working and not creating any regression?

ulgens reacted with heart emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It appears that usingPOST for logout has been available from the start (for the view we are using at least). So as long as we get the form action and CSRF right, it should be fine.

I added a test that specifically checks for the form declaration. If you had something other in your mind, let me know.

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

Reviewers

@lovelydinosaurlovelydinosaurlovelydinosaur left review comments

@auvipyauvipyauvipy approved these changes

+1 more reviewer

@ulgensulgensulgens approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

3.15

Development

Successfully merging this pull request may close these issues.

rest_framework.urls doesn't work with LogoutView in Django 5.0

4 participants

@realsuayip@ulgens@lovelydinosaur@auvipy

[8]ページ先頭

©2009-2025 Movatter.jp