Handle missing SMS OTP config, missing user TOTP config

This commit is contained in:
Kumi 2021-12-06 18:36:33 +01:00
parent 8c42b386f3
commit 81c536c70a
5 changed files with 12 additions and 8 deletions

View file

@ -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.'''
return self.is_active
try:
return self.is_active
except RuntimeError:
return False
def start_authentication(self, user):
return "Authentication started, please enter your 2FA token."

View file

@ -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():
providers[name] = provider
except (AttributeError, ModuleNotFoundError):
if provider.is_active:
providers[name] = provider
except (AttributeError, ModuleNotFoundError, RuntimeError):
continue

View file

@ -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}")