mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 17:24:23 -04:00
Stop passing the 'whole' user object when making changes to profile
This commit is contained in:
@@ -47,8 +47,8 @@ def user_profile_name():
|
|||||||
form = ChangeNameForm(new_name=current_user.name)
|
form = ChangeNameForm(new_name=current_user.name)
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
current_user.name = form.new_name.data
|
user_api_client.update_user(current_user.id,
|
||||||
user_api_client.update_user(current_user)
|
name=form.new_name.data)
|
||||||
return redirect(url_for('.user_profile'))
|
return redirect(url_for('.user_profile'))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
@@ -107,7 +107,6 @@ def user_profile_email_authenticate():
|
|||||||
@main.route("/user-profile/email/confirm/<token>", methods=['GET'])
|
@main.route("/user-profile/email/confirm/<token>", methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def user_profile_email_confirm(token):
|
def user_profile_email_confirm(token):
|
||||||
|
|
||||||
token_data = check_token(token,
|
token_data = check_token(token,
|
||||||
current_app.config['SECRET_KEY'],
|
current_app.config['SECRET_KEY'],
|
||||||
current_app.config['DANGEROUS_SALT'],
|
current_app.config['DANGEROUS_SALT'],
|
||||||
@@ -115,9 +114,8 @@ def user_profile_email_confirm(token):
|
|||||||
token_data = json.loads(token_data)
|
token_data = json.loads(token_data)
|
||||||
user_id = token_data['user_id']
|
user_id = token_data['user_id']
|
||||||
new_email = token_data['email']
|
new_email = token_data['email']
|
||||||
user = user_api_client.get_user(user_id)
|
user_api_client.update_user(user_id,
|
||||||
user.email_address = new_email
|
email_address=new_email)
|
||||||
user_api_client.update_user(user)
|
|
||||||
session.pop(NEW_EMAIL, None)
|
session.pop(NEW_EMAIL, None)
|
||||||
|
|
||||||
return redirect(url_for('.user_profile'))
|
return redirect(url_for('.user_profile'))
|
||||||
@@ -179,10 +177,11 @@ def user_profile_mobile_number_confirm():
|
|||||||
form = ConfirmMobileNumberForm(_check_code)
|
form = ConfirmMobileNumberForm(_check_code)
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
current_user.mobile_number = session[NEW_MOBILE]
|
mobile_number = session[NEW_MOBILE]
|
||||||
del session[NEW_MOBILE]
|
del session[NEW_MOBILE]
|
||||||
del session[NEW_MOBILE_PASSWORD_CONFIRMED]
|
del session[NEW_MOBILE_PASSWORD_CONFIRMED]
|
||||||
user_api_client.update_user(current_user)
|
user_api_client.update_user(current_user.id,
|
||||||
|
mobile_number=mobile_number)
|
||||||
return redirect(url_for('.user_profile'))
|
return redirect(url_for('.user_profile'))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
@@ -202,8 +201,8 @@ def user_profile_password():
|
|||||||
form = ChangePasswordForm(_check_password)
|
form = ChangePasswordForm(_check_password)
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
current_user.set_password(form.new_password.data)
|
user_api_client.update_user(current_user.id,
|
||||||
user_api_client.update_user(current_user)
|
password=form.new_password.data)
|
||||||
return redirect(url_for('.user_profile'))
|
return redirect(url_for('.user_profile'))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ class UserApiClient(BaseAPIClient):
|
|||||||
users.append(User(user, max_failed_login_count=self.max_failed_login_count))
|
users.append(User(user, max_failed_login_count=self.max_failed_login_count))
|
||||||
return users
|
return users
|
||||||
|
|
||||||
def update_user(self, user):
|
def update_user(self, user_id, **kwargs):
|
||||||
data = user.serialize()
|
data = dict(**kwargs)
|
||||||
url = "/user/{}".format(user.id)
|
url = "/user/{}".format(user_id)
|
||||||
user_data = self.put(url, data=data)
|
user_data = self.put(url, data=data)
|
||||||
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
return User(user_data['data'], max_failed_login_count=self.max_failed_login_count)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user