mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 14:17:46 +00:00
Define a password from the CLI on user creation
Add a `-p/--password` option to `createuser` commands.
This commit is contained in:
parent
002d9edccc
commit
d9a18790d3
@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
|
||||
|
||||
## Latest
|
||||
|
||||
- [Feature] Modify ``createuser`` commands to define a password from the command line
|
||||
- [Improvement] Better yaml value parsing from command line
|
||||
- [Feature] Add `dev exec` command
|
||||
- [Bugfix] Fix incorrect notes settings definition
|
||||
|
@ -115,13 +115,20 @@ def init(root):
|
||||
@opts.root
|
||||
@click.option("--superuser", is_flag=True, help="Make superuser")
|
||||
@click.option("--staff", is_flag=True, help="Make staff user")
|
||||
@click.option(
|
||||
"-p",
|
||||
"--password",
|
||||
help="Specify password from the command line. If undefined, you will be prompted to input a password",
|
||||
)
|
||||
@click.argument("name")
|
||||
@click.argument("email")
|
||||
def createuser(root, superuser, staff, name, email):
|
||||
def createuser(root, superuser, staff, password, name, email):
|
||||
config = tutor_config.load(root)
|
||||
runner = K8sScriptRunner(root, config)
|
||||
runner.check_service_is_activated("lms")
|
||||
command = scripts.create_user_command(superuser, staff, name, email)
|
||||
command = scripts.create_user_command(
|
||||
superuser, staff, name, email, password=password
|
||||
)
|
||||
kubectl_exec(config, "lms", command, attach=True)
|
||||
|
||||
|
||||
|
@ -270,13 +270,20 @@ def logs(root, follow, tail, service):
|
||||
@opts.root
|
||||
@click.option("--superuser", is_flag=True, help="Make superuser")
|
||||
@click.option("--staff", is_flag=True, help="Make staff user")
|
||||
@click.option(
|
||||
"-p",
|
||||
"--password",
|
||||
help="Specify password from the command line. If undefined, you will be prompted to input a password",
|
||||
)
|
||||
@click.argument("name")
|
||||
@click.argument("email")
|
||||
def createuser(root, superuser, staff, name, email):
|
||||
def createuser(root, superuser, staff, password, name, email):
|
||||
config = tutor_config.load(root)
|
||||
runner = ScriptRunner(root, config)
|
||||
runner.check_service_is_activated("lms")
|
||||
command = scripts.create_user_command(superuser, staff, name, email)
|
||||
command = scripts.create_user_command(
|
||||
superuser, staff, name, email, password=password
|
||||
)
|
||||
runner.exec("lms", command)
|
||||
|
||||
|
||||
|
@ -58,17 +58,20 @@ def initialise(runner):
|
||||
fmt.echo_info("All services initialised.")
|
||||
|
||||
|
||||
def create_user_command(superuser, staff, username, email):
|
||||
def create_user_command(superuser, staff, username, email, password=None):
|
||||
opts = ""
|
||||
if superuser:
|
||||
opts += " --superuser"
|
||||
if staff:
|
||||
opts += " --staff"
|
||||
command = (
|
||||
"./manage.py lms --settings=tutor.production manage_user {opts} {username} {email}\n"
|
||||
"./manage.py lms --settings=tutor.production changepassword {username}"
|
||||
).format(opts=opts, username=username, email=email)
|
||||
return command
|
||||
command = "./manage.py lms --settings=tutor.production manage_user {opts} {username} {email}\n"
|
||||
if password:
|
||||
command += "./manage.py lms --settings=tutor.production shell -c \"from django.contrib.auth import get_user_model; u = get_user_model().objects.get(username='{username}'); u.set_password('{password}'); u.save()\""
|
||||
else:
|
||||
command += (
|
||||
"./manage.py lms --settings=tutor.production changepassword {username}"
|
||||
)
|
||||
return command.format(opts=opts, username=username, email=email, password=password)
|
||||
|
||||
|
||||
def import_demo_course(runner):
|
||||
|
@ -1,2 +0,0 @@
|
||||
./manage.py lms --settings=tutor.production manage_user {{ OPTS }} {{ USERNAME }} {{ EMAIL }}
|
||||
./manage.py lms --settings=tutor.production changepassword {{ USERNAME }}
|
Loading…
Reference in New Issue
Block a user