Fix inviting existing users

The API needs the id of the user, not the id of the invite.

The problem with the tests is that the update mock returned a different
user ID than the user it was being passed. So the tests didn’t catch
this.
This commit is contained in:
Chris Hill-Scott
2019-06-06 17:24:48 +01:00
parent f2303ff20a
commit 6130004b0c
3 changed files with 6 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ def accept_invite(token):
invited_user.auth_type == 'email_auth'
):
existing_user.update(auth_type=invited_user.auth_type)
invited_user.add_to_service()
invited_user.add_to_service(existing_user_id=existing_user.id)
return redirect(url_for('main.service_dashboard', service_id=service.id))
else:
return redirect(url_for('main.register_from_invite'))

View File

@@ -348,10 +348,10 @@ class InvitedUser(JSONModel):
def accept_invite(self):
invite_api_client.accept_invite(self.service, self.id)
def add_to_service(self):
def add_to_service(self, existing_user_id):
user_api_client.add_user_to_service(
self.service,
self.id,
existing_user_id,
self.permissions,
self.folder_permissions,
)