Created
August 29, 2014 10:21
-
-
Save daddz/1497d2c1d38402c2d2e6 to your computer and use it in GitHub Desktop.
Django custom AUTH_USER_MODEL password as plaintext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## customauth/admin.py | |
from django.contrib import admin | |
from customauth.models import MyUser | |
admin.site.register(MyUser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## start the app | |
$ ./manage.py makemigrations | |
$ ./manage.py migrate | |
$ ./manage.py createsuperuser | |
$ ./manage.py runserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## http://localhost:8000/admin/customauth/myuser | |
Add User -> Put something in "Password" and "Username" -> Save and continue editing | |
RESULT: password saved as plaintext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## customauth/models.py | |
from django.db import models | |
from django.contrib.auth.models import AbstractUser | |
class MyUser(AbstractUser): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## isthisabug/settings.py | |
""" | |
... | |
""" | |
INSTALLED_APPS = ( | |
""" ... """ | |
'customauth', | |
) | |
AUTH_USER_MODEL = 'customauth.MyUser' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## start with a new Django project | |
$ pip freeze -l | |
> Django==1.7c3 | |
$ django-admin startproject isthisabug | |
$ cd isthisabug | |
$ ./manage.py startapp customauth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment