forked from GithubBackups/healthchecks
createsuperuser management command requires an unique email address (#318)
This commit is contained in:
parent
4ee2646539
commit
012ad88bb3
@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- Show a red "!" in project's top navigation if any integration is not working
|
- Show a red "!" in project's top navigation if any integration is not working
|
||||||
|
- createsuperuser management command requires an unique email address (#318)
|
||||||
|
|
||||||
|
|
||||||
## v1.12.0 - 2020-01-02
|
## v1.12.0 - 2020-01-02
|
||||||
|
43
hc/accounts/management/commands/createsuperuser.py
Normal file
43
hc/accounts/management/commands/createsuperuser.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import getpass
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from hc.accounts.forms import AvailableEmailForm
|
||||||
|
from hc.accounts.views import _make_user
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = """Create a super-user account."""
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
email = None
|
||||||
|
password = None
|
||||||
|
|
||||||
|
while not email:
|
||||||
|
raw = input("Email address:")
|
||||||
|
form = AvailableEmailForm({"identity": raw})
|
||||||
|
if not form.is_valid():
|
||||||
|
print(dir(form))
|
||||||
|
self.stderr.write("Error: " + " ".join(form.errors["identity"]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
email = form.cleaned_data["identity"]
|
||||||
|
|
||||||
|
while not password:
|
||||||
|
p1 = getpass.getpass()
|
||||||
|
p2 = getpass.getpass("Password (again):")
|
||||||
|
if p1.strip() == "":
|
||||||
|
self.stderr.write("Error: Blank passwords aren't allowed.")
|
||||||
|
continue
|
||||||
|
if p1 != p2:
|
||||||
|
self.stderr.write("Error: Your passwords didn't match.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
password = p1
|
||||||
|
|
||||||
|
user = _make_user(email)
|
||||||
|
user.set_password(password)
|
||||||
|
user.is_staff = True
|
||||||
|
user.is_superuser = True
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
return "Superuser created successfully."
|
@ -43,6 +43,7 @@ with open(os.path.join(BASE_DIR, "CHANGELOG.md"), encoding="utf-8") as f:
|
|||||||
|
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
|
"hc.accounts",
|
||||||
"django.contrib.admin",
|
"django.contrib.admin",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
@ -51,7 +52,6 @@ INSTALLED_APPS = (
|
|||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
"compressor",
|
"compressor",
|
||||||
"hc.accounts",
|
|
||||||
"hc.api",
|
"hc.api",
|
||||||
"hc.front",
|
"hc.front",
|
||||||
"hc.payments",
|
"hc.payments",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user