mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
add facilities to rehash on login passwords if parameters change
This commit is contained in:
@@ -86,6 +86,16 @@ class PasswordHasher(with_metaclass(MetaHasher, object)):
|
||||
hashed_value
|
||||
)
|
||||
|
||||
def needs_rehash(self, hashed_value):
|
||||
"""Check if the provided hash needs rehasing accoring to the current
|
||||
parameters
|
||||
|
||||
:param str hashed_value: hased password
|
||||
:rtype bool
|
||||
:return: True if the password needs rehash, false otherwise
|
||||
"""
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def get_password_hashers(cls):
|
||||
"""Return all the PasswordHasher supported by Modoboa"""
|
||||
|
||||
@@ -52,6 +52,14 @@ def dologin(request):
|
||||
)
|
||||
user.set_password(form.cleaned_data["password"])
|
||||
user.save()
|
||||
if pwhash.needs_rehash(user.password):
|
||||
logging.info(
|
||||
_("Password hash parameter missmatch. "
|
||||
"Updating %s password"),
|
||||
user.username
|
||||
)
|
||||
user.set_password(form.cleaned_data["password"])
|
||||
user.save()
|
||||
|
||||
login(request, user)
|
||||
if not form.cleaned_data["rememberme"]:
|
||||
|
||||
Reference in New Issue
Block a user