Ensure non-gov invited users get added to services

We were adding invited users to services in the `main.add_service` view
function as the last step in the process of inviting users. Since this
view function is decorated with `@user_is_gov_user`, invited users with
non-governmental email addresses would never reach this point and would
be able to register an account but would not get linked to a service.

To fix this, we now add the invited user to the service at the point at
which the user gets activated and also ensure that non-gov users don't
get redirected to a page which they don't have permission to view.
This commit is contained in:
Katie Smith
2019-01-18 16:13:29 +00:00
parent 63889cb047
commit bbc7b173f0
4 changed files with 29 additions and 27 deletions

View File

@@ -68,7 +68,6 @@ def register_from_org_invite():
abort(400)
_do_registration(form, send_email=False, send_sms=True, organisation_id=invited_org_user['organisation'])
org_invite_api_client.accept_invite(invited_org_user['organisation'], invited_org_user['id'])
user_api_client.add_user_to_organisation(invited_org_user['organisation'], session['user_details']['id'])
return redirect(url_for('main.verify'))
return render_template('views/register-from-org-invite.html', invited_org_user=invited_org_user, form=form)