Skip to content

Commit

Permalink
only allow lowercase email invites
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Dec 17, 2024
1 parent 99b5548 commit f66bc48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,9 @@ def accept(
"""
Raises: ValidationError
"""
assert invitee.email.lower() == self.email.lower(), "Email mismatch"
assert (
invitee.email and invitee.email.lower() == self.email.lower()
), "Email mismatch"

membership, created = WorkspaceMembership.objects.get_or_create(
workspace=self.workspace,
Expand Down
16 changes: 10 additions & 6 deletions workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _handle_invite_accepted(

workspace_redirect_url = get_route_path(account_route)

if invite.email.lower() != current_user.email.lower():
if not current_user.email or invite.email.lower() != current_user.email.lower():
# logout current user, and redirect to login
login_url = get_app_route_url(
login, query_params={"next": invite.get_invite_url()}
Expand Down Expand Up @@ -341,11 +341,15 @@ def clear_invite_creation_form():
def render_invite_creation_form(workspace: Workspace) -> tuple[str, str]:
gui.write(f"Invite to **{workspace.display_name()}**.")

email = gui.text_input(
"###### Email",
style=dict(minWidth="300px"),
key="invite-form-email",
).strip()
email = (
gui.text_input(
"###### Email",
style=dict(minWidth="300px", textTransform="lowercase"),
key="invite-form-email",
)
.strip()
.lower()
)

role = gui.selectbox(
"###### Role",
Expand Down

0 comments on commit f66bc48

Please sign in to comment.