amalshaji/portr

Initial Superuser can get in a "stuck" state

imnotjames opened this issue ยท 2 comments

Describe the bug
If a super user is created but then - say, because they get distracted watching Galaxy of Terror ๐Ÿ˜… - gets logged out without creating a team, they're stuck. They can't authenticate again that way because they aren't on a team, they never created one.

To Reproduce
Steps to reproduce the behavior:

  1. Set up an empty portr instance
  2. Log in and create the first superuser but DO NOT create a team
  3. Delete cookie for session
  4. Attempt to Log in again
  5. See error message

Expected behavior
Superuser can log in even if they aren't on a team - so they can create a team

Screenshots

Error message is shown User not part of any team

Additional context
Fixed as part of #25 but there's a number of other changes there..

Is the first user getting stuck? This solves it, right?

first_team = await user.teams.filter().first()
if first_team is None:
return RedirectResponse(url="/new-team")

That kind of check could work but that would just redirect the user after they're logged in.

The issue is that the user cannot log back in again - if they're logged out they're not able to log back in without an error message.