You don't really need to change django to do this.
I've solved this with User class hook:
def my_set_password(user, raw_password):
try:
this = EMailInfo.objects.get(user=user)
except EMailInfo.DoesNotExist:
this = EMailInfo(user=user)
this.username = user.username
import sha
this.password =
'{SHA}'+base64_encode(sha.new(raw_password).digest())[0].strip()
this.email= '%s@%s' % (user.username, VIRTUAL_DOMAIN)
user.emailaddress = this
def my_create_user(manager, username, email, password):
user = real_create_user(manager, username, email, password)
# user was saved after this
this = user.emailaddress
this.user = user
this.username = user.username
this.save()
return user
real_set_password = User.set_password
User.set_password = my_set_password
real_create_user = UserManager.create_user
UserManager.create_user = my_create_user
> [1] http://code.djangoproject.com/changeset/5073
> [2] http://code.djangoproject.com/ticket/3316
> [3] http://linux.die.net/man/3/crypt
> [4] http://code.djangoproject.com/ticket/6028
--
Best regards, Yuri V. Baburov, ICQ# 99934676, Skype: yuri.baburov,
MSN: bu...@live.com
With my solution all will be perfect if you will have additional table
for those old passwords.
And your solution can be even more simple -- create your own function
for authentication backend and hook only set_password(user,
raw_password) with your own your_set_password and do
real_set_password = User.set_password
User.set_password = your_set_password ;)
But your patches are useful though. +0 from me.
Btw, what did you want to achieve with discussion in django-dev?