invitation cannot be reused if wrong user accepts it
This commit is contained in:
parent
0a176239b7
commit
cb25dcdd32
@ -70,6 +70,8 @@ class Invitations(object):
|
|||||||
invite = Invitations._get(token)
|
invite = Invitations._get(token)
|
||||||
|
|
||||||
if invite.user.dod_id != user.dod_id:
|
if invite.user.dod_id != user.dod_id:
|
||||||
|
if invite.is_pending:
|
||||||
|
Invitations._update_status(invite, InvitationStatus.REJECTED)
|
||||||
raise WrongUserError(user, invite)
|
raise WrongUserError(user, invite)
|
||||||
|
|
||||||
elif invite.is_expired:
|
elif invite.is_expired:
|
||||||
|
@ -75,6 +75,16 @@ def test_wrong_user_accepts_invitation():
|
|||||||
Invitations.accept(wrong_user, invite.token)
|
Invitations.accept(wrong_user, invite.token)
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_cannot_accept_invitation_accepted_by_wrong_user():
|
||||||
|
user = UserFactory.create()
|
||||||
|
wrong_user = UserFactory.create()
|
||||||
|
invite = InvitationFactory.create(user_id=user.id)
|
||||||
|
with pytest.raises(WrongUserError):
|
||||||
|
Invitations.accept(wrong_user, invite.token)
|
||||||
|
with pytest.raises(InvitationError):
|
||||||
|
Invitations.accept(user, invite.token)
|
||||||
|
|
||||||
|
|
||||||
def test_accept_invitation_twice():
|
def test_accept_invitation_twice():
|
||||||
workspace = WorkspaceFactory.create()
|
workspace = WorkspaceFactory.create()
|
||||||
user = UserFactory.create()
|
user = UserFactory.create()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user