Improve logging

This commit is contained in:
Tanner Collin 2021-01-12 02:42:53 +00:00
parent a7051f80ac
commit 247e221ac6
2 changed files with 11 additions and 0 deletions

View File

@ -530,9 +530,16 @@ class MyPasswordChangeSerializer(PasswordChangeSerializer):
class MyPasswordResetSerializer(PasswordResetSerializer): class MyPasswordResetSerializer(PasswordResetSerializer):
def validate_email(self, email): def validate_email(self, email):
if not User.objects.filter(email__iexact=email).exists(): if not User.objects.filter(email__iexact=email).exists():
logging.info('Email not found: ' + email)
raise ValidationError('Not found.') raise ValidationError('Not found.')
return super().validate_email(email) return super().validate_email(email)
def save(self):
email = self.data['email']
member = User.objects.get(email__iexact=email).member
logging.info('Password reset requested for: {} - {} {} ({})'.format(email, member.first_name, member.last_name, member.id))
super().save()
class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer): class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
def save(self): def save(self):
data = dict( data = dict(
@ -559,6 +566,9 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
logger.info(msg) logger.info(msg)
raise ValidationError(dict(non_field_errors=msg)) raise ValidationError(dict(non_field_errors=msg))
member = self.user.member
logging.info('Password reset completed for: {} {} ({})'.format(member.first_name, member.last_name, member.id))
super().save() super().save()

View File

@ -84,6 +84,7 @@ class SearchViewSet(Base, Retrieve):
result_objects = [queryset.get(id=x) for x in result_ids] result_objects = [queryset.get(id=x) for x in result_ids]
queryset = result_objects queryset = result_objects
logging.info('Search for: {}, results: {}'.format(search, len(queryset)))
elif self.action == 'create': elif self.action == 'create':
utils.gen_search_strings() # update cache utils.gen_search_strings() # update cache
queryset = queryset.order_by('-vetted_date') queryset = queryset.order_by('-vetted_date')