Handle missing SMS OTP config, missing user TOTP config
This commit is contained in:
parent
8c42b386f3
commit
81c536c70a
5 changed files with 12 additions and 8 deletions
|
@ -19,7 +19,10 @@ class BaseOTPProvider:
|
|||
|
||||
def active_for_user(self, user):
|
||||
'''Returns True if the provider is active and ready to be used by user.'''
|
||||
try:
|
||||
return self.is_active
|
||||
except RuntimeError:
|
||||
return False
|
||||
|
||||
def start_authentication(self, user):
|
||||
return "Authentication started, please enter your 2FA token."
|
||||
|
|
|
@ -8,6 +8,7 @@ for module in settings.EXPEPHALON_MODULES:
|
|||
try:
|
||||
moo = importlib.import_module(f"{module}.otp")
|
||||
for name, provider in moo.OTPPROVIDERS.items():
|
||||
if provider.is_active:
|
||||
providers[name] = provider
|
||||
except (AttributeError, ModuleNotFoundError):
|
||||
except (AttributeError, ModuleNotFoundError, RuntimeError):
|
||||
continue
|
|
@ -19,7 +19,7 @@ for module in settings.EXPEPHALON_MODULES:
|
|||
providers.append(provider)
|
||||
if mos.CREATE:
|
||||
modules_available.append(mos.CREATE)
|
||||
except (AttributeError, ModuleNotFoundError):
|
||||
except (AttributeError, ModuleNotFoundError, RuntimeError):
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.error("Error importing SMS module {module}: {e}")
|
||||
|
|
Loading…
Reference in a new issue