mirror of https://github.com/zulip/zulip.git
models: Add USER_CHANGE_PASSWORD event type constant to RealmAuditLog.
This commit is contained in:
parent
201b99a6f8
commit
4c73221108
|
@ -2794,7 +2794,7 @@ def do_change_password(user_profile: UserProfile, password: str, commit: bool=Tr
|
||||||
user_profile.save(update_fields=["password"])
|
user_profile.save(update_fields=["password"])
|
||||||
event_time = timezone_now()
|
event_time = timezone_now()
|
||||||
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=user_profile,
|
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=user_profile,
|
||||||
modified_user=user_profile, event_type='user_change_password',
|
modified_user=user_profile, event_type=RealmAuditLog.USER_CHANGE_PASSWORD,
|
||||||
event_time=event_time)
|
event_time=event_time)
|
||||||
|
|
||||||
def do_change_full_name(user_profile: UserProfile, full_name: str,
|
def do_change_full_name(user_profile: UserProfile, full_name: str,
|
||||||
|
|
|
@ -1966,6 +1966,7 @@ class RealmAuditLog(models.Model):
|
||||||
USER_ACTIVATED = 'user_activated'
|
USER_ACTIVATED = 'user_activated'
|
||||||
USER_DEACTIVATED = 'user_deactivated'
|
USER_DEACTIVATED = 'user_deactivated'
|
||||||
USER_REACTIVATED = 'user_reactivated'
|
USER_REACTIVATED = 'user_reactivated'
|
||||||
|
USER_CHANGE_PASSWORD = 'user_change_password'
|
||||||
|
|
||||||
event_type = models.CharField(max_length=40) # type: str
|
event_type = models.CharField(max_length=40) # type: str
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||||
user = self.example_user('hamlet')
|
user = self.example_user('hamlet')
|
||||||
password = 'test1'
|
password = 'test1'
|
||||||
do_change_password(user, password)
|
do_change_password(user, password)
|
||||||
self.assertEqual(RealmAuditLog.objects.filter(event_type='user_change_password',
|
self.assertEqual(RealmAuditLog.objects.filter(event_type=RealmAuditLog.USER_CHANGE_PASSWORD,
|
||||||
event_time__gte=now).count(), 1)
|
event_time__gte=now).count(), 1)
|
||||||
self.assertIsNone(validate_password(password, user))
|
self.assertIsNone(validate_password(password, user))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue