Display progress updates during password resets

This commit is contained in:
2021-09-18 21:12:14 +00:00
parent 33a95d0604
commit 95295a712e
2 changed files with 28 additions and 0 deletions

View File

@@ -615,12 +615,15 @@ class MyPasswordResetSerializer(PasswordResetSerializer):
class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
def save(self):
request_id = self.data['token'][-10:]
data = dict(
username=self.user.username,
password1=self.data['new_password1'],
)
if utils_ldap.is_configured():
if request_id: utils_stats.set_progress(request_id, 'Changing LDAP password...')
if utils_ldap.set_password(data) != 200:
msg = 'Problem connecting to LDAP server: set.'
utils.alert_tanner(msg)
@@ -635,6 +638,7 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
)
if utils_auth.wiki_is_configured():
if request_id: utils_stats.set_progress(request_id, 'Changing Wiki password...')
if utils_auth.set_wiki_password(data) != 200:
msg = 'Problem connecting to Wiki Auth server: set.'
utils.alert_tanner(msg)
@@ -642,6 +646,7 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
raise ValidationError(dict(non_field_errors=msg))
if utils_auth.discourse_is_configured():
if request_id: utils_stats.set_progress(request_id, 'Changing Discourse password...')
if utils_auth.set_discourse_password(data) != 200:
msg = 'Problem connecting to Discourse Auth server: set.'
utils.alert_tanner(msg)
@@ -651,6 +656,9 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
member = self.user.member
logging.info('Password reset completed for: {} {} ({})'.format(member.first_name, member.last_name, member.id))
if request_id: utils_stats.set_progress(request_id, 'Done!')
time.sleep(1)
super().save()