mirror of https://github.com/jumpserver/jumpserver
39.102.214.101 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOzDdXgVjgKrT+ZF5DXcNZqJnkjwvt0M5FbVpvbTOU/v
perf: save_passwd_change filter user source local and passwords not emtpypull/13673/head
parent
c6befe4c4b
commit
5c1d0238e1
|
@ -67,12 +67,18 @@ def user_authenticated_handle(user, created, source, attrs=None, **kwargs):
|
|||
|
||||
@receiver(post_save, sender=User)
|
||||
def save_passwd_change(sender, instance: User, **kwargs):
|
||||
if instance.source != User.Source.local.value:
|
||||
return
|
||||
|
||||
passwords = UserPasswordHistory.objects \
|
||||
.filter(user=instance) \
|
||||
.order_by('-date_created') \
|
||||
.values_list('password', flat=True)
|
||||
passwords = passwords[:int(settings.OLD_PASSWORD_HISTORY_LIMIT_COUNT)]
|
||||
|
||||
if not passwords:
|
||||
return
|
||||
|
||||
for p in passwords:
|
||||
if instance.password == p:
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue