From 3f91dcb7afecd14c876a5c7ce81ecdffef880f72 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 6 Jul 2021 13:48:53 +0200 Subject: [PATCH 1/2] compile scheme list using a generator --- core/admin/mailu/models.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index b5ba29c0..a86e005f 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -507,13 +507,13 @@ class User(Base, Email): if cls._ctx: return cls._ctx - schemes = passlib.registry.list_crypt_handlers() - # scrypt throws a warning if the native wheels aren't found - schemes.remove('scrypt') - # we can't leave plaintext schemes as they will be misidentified - for scheme in schemes: - if scheme.endswith('plaintext'): - schemes.remove(scheme) + # compile schemes + # - scrypt throws a warning if the native wheels aren't found + # - we can't leave plaintext schemes as they will be misidentified + schemes = [ + scheme for scheme in passlib.registry.list_crypt_handlers() + if not (scheme == 'scrypt' or scheme.endswith('plaintext')) + ] cls._ctx = passlib.context.CryptContext( schemes=schemes, default='bcrypt_sha256', From c2c3030a2f80bf0ae85d186d30a47ca97b9ce81b Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 24 Jul 2021 20:54:36 +0200 Subject: [PATCH 2/2] rephrased comments --- core/admin/mailu/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index a86e005f..43f7196a 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -508,8 +508,8 @@ class User(Base, Email): return cls._ctx # compile schemes - # - scrypt throws a warning if the native wheels aren't found - # - we can't leave plaintext schemes as they will be misidentified + # - skip scrypt (throws a warning if the native wheels aren't found) + # - skip plaintext schemes (will be misidentified) schemes = [ scheme for scheme in passlib.registry.list_crypt_handlers() if not (scheme == 'scrypt' or scheme.endswith('plaintext'))