Skip to content

Commit

Permalink
[#4955] Add script to populate password history data
Browse files Browse the repository at this point in the history
  • Loading branch information
zuhdil committed Aug 14, 2023
1 parent da007ae commit ad4209d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
from akvo.password_policy.models import PasswordHistory


class Command(BaseCommand):
help = "Populate user's password history"

def handle(self, *args, **options):
existed = PasswordHistory.objects.values('user')
for user in get_user_model().objects.exclude(id__in=existed):
PasswordHistory.objects.create(user=user, password=user.password)

0 comments on commit ad4209d

Please sign in to comment.