clean up logic around existing users accepting invites

* if the service issuing the invite does not have permission to edit
  auth types, don't let them do anything. This will stop them turning
  existing email_auth users back to sms auth
* if the user hasn't got a mobile number, but the invite is for sms
  login, don't do anything either. They won't have a phone number if
  they signed up via an email_auth invite previously.

in these cases, we accept the invite and add the user to the service
as normal, however, just don't update the user's auth type.
This commit is contained in:
Leo Hemsted
2017-11-15 17:19:32 +00:00
parent ab4504f517
commit ddf88b70c0
5 changed files with 122 additions and 18 deletions

View File

@@ -47,8 +47,7 @@ def user_profile_name():
form = ChangeNameForm(new_name=current_user.name)
if form.validate_on_submit():
user_api_client.update_user_attribute(current_user.id,
name=form.new_name.data)
user_api_client.update_user_attribute(current_user.id, name=form.new_name.data)
return redirect(url_for('.user_profile'))
return render_template(
@@ -114,8 +113,7 @@ def user_profile_email_confirm(token):
token_data = json.loads(token_data)
user_id = token_data['user_id']
new_email = token_data['email']
user_api_client.update_user_attribute(user_id,
email_address=new_email)
user_api_client.update_user_attribute(user_id, email_address=new_email)
session.pop(NEW_EMAIL, None)
return redirect(url_for('.user_profile'))
@@ -183,8 +181,7 @@ def user_profile_mobile_number_confirm():
mobile_number = session[NEW_MOBILE]
del session[NEW_MOBILE]
del session[NEW_MOBILE_PASSWORD_CONFIRMED]
user_api_client.update_user_attribute(current_user.id,
mobile_number=mobile_number)
user_api_client.update_user_attribute(current_user.id, mobile_number=mobile_number)
return redirect(url_for('.user_profile'))
return render_template(