Skip to content

Conversation

@Peter2552
Copy link

Fixes #341

This pull request prevents logged-in users from accessing the registration and login pages.

Changes made

  • Added a redirection in PytitionUserCreateView to prevent logged-in users from viewing /petition/register/.
  • Created a CustomLoginView to redirect logged-in users away from /petition/login/.
  • Updated urls.py to use the custom login view.

Expected behavior

  • Anonymous users: can access /petition/register/ and /petition/login/.
  • Logged-in users: are redirected to the home page (/petition/).

Testing

Tested locally with Docker:

  • Confirmed redirection works correctly for logged-in users.
  • Verified that registration and login work as expected for anonymous users.

Thanks for the opportunity to contribute to Pytition!

@Peter2552
Copy link
Author

PS: While testing this, I implemented a simple logout route locally for debugging.
It’s not part of this PR, but I can open a new issue if you’d like that functionality officially added.

@fallen fallen self-requested a review November 5, 2025 11:22
@fallen fallen self-assigned this Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registration page should not be reachable for logged-in users

2 participants