Start conversion for Django 2.0; change to auth for compatibility
This commit is contained in:
parent
fbfae59138
commit
f9354d9aeb
3 changed files with 11 additions and 18 deletions
|
|
@ -595,29 +595,18 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
||||||
|
|
||||||
return valid, error
|
return valid, error
|
||||||
|
|
||||||
def set_password(self, password, force=False):
|
def set_password(self, password, **kwargs):
|
||||||
"""
|
"""
|
||||||
Applies the given password to the account if it passes validation checks.
|
Applies the given password to the account. Logs and triggers the `at_password_change` hook.
|
||||||
Can be overridden by using the 'force' flag.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
password (str): Password to set
|
password (str): Password to set.
|
||||||
|
|
||||||
Kwargs:
|
Notes:
|
||||||
force (bool): Sets password without running validation checks.
|
This is called by Django also when logging in; it should not be mixed up with validation, since that
|
||||||
|
would mean old passwords in the database (pre validation checks) could get invalidated.
|
||||||
Raises:
|
|
||||||
ValidationError
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
None (None): Does not return a value.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not force:
|
|
||||||
# Run validation checks
|
|
||||||
valid, error = self.validate_password(password, account=self)
|
|
||||||
if error: raise error
|
|
||||||
|
|
||||||
super(DefaultAccount, self).set_password(password)
|
super(DefaultAccount, self).set_password(password)
|
||||||
logger.log_sec("Password successfully changed for %s." % self)
|
logger.log_sec("Password successfully changed for %s." % self)
|
||||||
self.at_password_change()
|
self.at_password_change()
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ SRESET = chr(19) # shutdown server in reset mode
|
||||||
PYTHON_MIN = '3.7'
|
PYTHON_MIN = '3.7'
|
||||||
TWISTED_MIN = '18.0.0'
|
TWISTED_MIN = '18.0.0'
|
||||||
DJANGO_MIN = '1.11'
|
DJANGO_MIN = '1.11'
|
||||||
DJANGO_REC = '1.11'
|
DJANGO_REC = '2.0'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.path[1] = EVENNIA_ROOT
|
sys.path[1] = EVENNIA_ROOT
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,10 @@ def create_account(key, email, password,
|
||||||
new_account = typeclass(username=key, email=email,
|
new_account = typeclass(username=key, email=email,
|
||||||
is_staff=is_superuser, is_superuser=is_superuser,
|
is_staff=is_superuser, is_superuser=is_superuser,
|
||||||
last_login=now, date_joined=now)
|
last_login=now, date_joined=now)
|
||||||
|
valid, error = new_account.validate_password(password, new_account)
|
||||||
|
if not valid:
|
||||||
|
raise error
|
||||||
|
|
||||||
new_account.set_password(password)
|
new_account.set_password(password)
|
||||||
new_account._createdict = dict(locks=locks, permissions=permissions, report_to=report_to,
|
new_account._createdict = dict(locks=locks, permissions=permissions, report_to=report_to,
|
||||||
tags=tags, attributes=attributes)
|
tags=tags, attributes=attributes)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue