perf: 优化perm tree, 并添加缓存

This commit is contained in:
ibuler
2022-03-08 13:35:40 +08:00
committed by Jiangjie.Bai
parent cb072123d6
commit 5081fb5fe7
4 changed files with 69 additions and 142 deletions

View File

@@ -43,10 +43,12 @@ def user_authenticated_handle(user, created, source, attrs=None, **kwargs):
@receiver(post_save, sender=User)
def save_passwd_change(sender, instance: User, **kwargs):
passwds = UserPasswordHistory.objects.filter(user=instance).order_by('-date_created')\
.values_list('password', flat=True)[:int(settings.OLD_PASSWORD_HISTORY_LIMIT_COUNT)]
passwords = UserPasswordHistory.objects.filter(user=instance) \
.order_by('-date_created')\
.values_list('password', flat=True)
passwords = passwords[:int(settings.OLD_PASSWORD_HISTORY_LIMIT_COUNT)]
for p in passwds:
for p in passwords:
if instance.password == p:
break
else: