Dynavera/apps/accounts/management/commands/reset_passwords.py

14 lines
571 B
Python
Raw Normal View History

from django.core.management.base import BaseCommand
2026-02-26 11:12:49 +00:00
from accounts.models import User
class Command(BaseCommand):
help = 'Resets non-admin account passwords to "password" and admin account passwords to "admin" using the current SECRET_KEY'
def handle(self, *args, **kwargs):
for user in User.objects.all():
if user.is_staff:
user.set_password('admin')
else:
user.set_password('password')
user.save()
self.stdout.write("All account passwords synchronized with local SECRET_KEY.")