Add hashed_password argument to do_change_password.

This way we're not directly manipulating user.password() in random
management commands.

(imported from commit e6e32ae422015ab55184d5d8111148793a8aca36)
This commit is contained in:
Tim Abbott
2013-03-29 13:36:27 -04:00
parent 80747567c0
commit 9317035fc7
3 changed files with 15 additions and 10 deletions

View File

@@ -443,9 +443,14 @@ def do_activate_user(user_profile, log=True, join_date=timezone.now()):
'user': user.email,
'domain': domain})
def do_change_password(user_profile, password, log=True, commit=True):
def do_change_password(user_profile, password, log=True, commit=True,
hashed_password=False):
user = user_profile.user
user.set_password(password)
if hashed_password:
# This is a hashed password, not the password itself.
user.password = password
else:
user.set_password(password)
if commit:
user.save(update_fields=["password"])
if log: