2016-10-12 16:26:19 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from openslides.users.models import User
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
"""
|
|
|
|
Command to change a user's password.
|
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
help = "Changes user password."
|
2016-10-12 16:26:19 +02:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument(
|
2019-01-06 16:22:33 +01:00
|
|
|
"username", help="The name of the user to set the password for"
|
2016-10-12 16:26:19 +02:00
|
|
|
)
|
2019-01-06 16:22:33 +01:00
|
|
|
parser.add_argument("password", help="The new password of the user")
|
2016-10-12 16:26:19 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2019-01-06 16:22:33 +01:00
|
|
|
user = User.objects.get(username=options["username"])
|
|
|
|
user.set_password(options["password"])
|
2016-10-12 16:26:19 +02:00
|
|
|
user.save()
|