mirror of
https://github.com/optim-enterprises-bv/Mailu.git
synced 2025-11-02 11:08:01 +00:00
Merge branch 'master' into fix-sender-checks
This commit is contained in:
@@ -287,8 +287,10 @@ class User(Base, Email):
|
||||
|
||||
def get_id(self):
|
||||
return self.email
|
||||
|
||||
scheme_dict = {'SHA512-CRYPT': "sha512_crypt",
|
||||
|
||||
scheme_dict = {'PBKDF2': "pbkdf2_sha512",
|
||||
'BLF-CRYPT': "bcrypt",
|
||||
'SHA512-CRYPT': "sha512_crypt",
|
||||
'SHA256-CRYPT': "sha256_crypt",
|
||||
'MD5-CRYPT': "md5_crypt",
|
||||
'CRYPT': "des_crypt"}
|
||||
@@ -298,8 +300,14 @@ class User(Base, Email):
|
||||
)
|
||||
|
||||
def check_password(self, password):
|
||||
context = User.pw_context
|
||||
reference = re.match('({[^}]+})?(.*)', self.password).group(2)
|
||||
return User.pw_context.verify(password, reference)
|
||||
result = context.verify(password, reference)
|
||||
if result and context.identify(reference) != context.default_scheme():
|
||||
self.set_password(password)
|
||||
db.session.add(self)
|
||||
db.session.commit()
|
||||
return result
|
||||
|
||||
def set_password(self, password, hash_scheme=app.config['PASSWORD_SCHEME'], raw=False):
|
||||
"""Set password for user with specified encryption scheme
|
||||
|
||||
Reference in New Issue
Block a user