Support invite codes for verification of email
Also changes the system so we don't apply the invite until it is called explicitly from the frontend Fixes #241
This commit is contained in:
parent
5d86fa80e7
commit
687bab1c05
7 changed files with 3185 additions and 35 deletions
|
@ -253,9 +253,26 @@ def delete_team_invite(code, user_obj=None):
|
|||
return (team, inviter)
|
||||
|
||||
|
||||
def confirm_team_invite(code, user_obj):
|
||||
def find_matching_team_invite(code, user_obj):
|
||||
""" Finds a team invite with the given code that applies to the given user and returns it or
|
||||
raises a DataModelException if not found. """
|
||||
found = lookup_team_invite(code)
|
||||
|
||||
# If the invite is for a specific user, we have to confirm that here.
|
||||
if found.user is not None and found.user != user_obj:
|
||||
message = """This invite is intended for user "%s".
|
||||
Please login to that account and try again.""" % found.user.username
|
||||
raise DataModelException(message)
|
||||
|
||||
return found
|
||||
|
||||
|
||||
def confirm_team_invite(code, user_obj):
|
||||
""" Confirms the given team invite code for the given user by adding the user to the team
|
||||
and deleting the code. Raises a DataModelException if the code was not found or does
|
||||
not apply to the given user. """
|
||||
found = find_matching_team_invite(code, user_obj)
|
||||
|
||||
# If the invite is for a specific user, we have to confirm that here.
|
||||
if found.user is not None and found.user != user_obj:
|
||||
message = """This invite is intended for user "%s".
|
||||
|
|
Reference in a new issue