amerkurev / django-docker-template

Dockerized Django with Postgres, Gunicorn, and Traefik or Caddy (with auto renew Let's Encrypt)
https://django-docker.dev
MIT License
169 stars 33 forks source link

get_or_create() does not hash passwords #20

Closed nbovee closed 1 month ago

nbovee commented 1 month ago

Heya, a small fix needed for safecreatesuperuser.py.

Using get_or_create directly sets fields, and does not hash the password.

/usr/src/website # python manage.py dumpdata auth.user
[{
  "model": "auth.user",
  "pk": 1,
  "fields": {
    "password": "admin",
    "last_login": null, 
    "is_superuser": true,
    "username": "admin",
    "first_name": "",
    "last_name": "",
    "email": "admin@example.com",
    "is_staff": true,
    "is_active": true,
    "date_joined": "2024-06-03T21:27:21.811Z",
    "groups": [],
    "user_permissions": []
  }
}]

I'll have a PR in momentarily.

amerkurev commented 1 month ago

@nbovee Can I close this issue? I merged your last PR and it fixed this issue, didn't it?

nbovee commented 1 month ago

Yes I think the issue is done. I will be adding the USER_EXISTS checking like in docker-cmd.sh, for safety if users run it on an active database, but that is not a part of the bug.