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):
|
def active_for_user(self, user):
|
||||||
'''Returns True if the provider is active and ready to be used by user.'''
|
'''Returns True if the provider is active and ready to be used by user.'''
|
||||||
|
try:
|
||||||
return self.is_active
|
return self.is_active
|
||||||
|
except RuntimeError:
|
||||||
|
return False
|
||||||
|
|
||||||
def start_authentication(self, user):
|
def start_authentication(self, user):
|
||||||
return "Authentication started, please enter your 2FA token."
|
return "Authentication started, please enter your 2FA token."
|
||||||
|
|
|
@ -8,6 +8,7 @@ for module in settings.EXPEPHALON_MODULES:
|
||||||
try:
|
try:
|
||||||
moo = importlib.import_module(f"{module}.otp")
|
moo = importlib.import_module(f"{module}.otp")
|
||||||
for name, provider in moo.OTPPROVIDERS.items():
|
for name, provider in moo.OTPPROVIDERS.items():
|
||||||
|
if provider.is_active:
|
||||||
providers[name] = provider
|
providers[name] = provider
|
||||||
except (AttributeError, ModuleNotFoundError):
|
except (AttributeError, ModuleNotFoundError, RuntimeError):
|
||||||
continue
|
continue
|
|
@ -19,7 +19,7 @@ for module in settings.EXPEPHALON_MODULES:
|
||||||
providers.append(provider)
|
providers.append(provider)
|
||||||
if mos.CREATE:
|
if mos.CREATE:
|
||||||
modules_available.append(mos.CREATE)
|
modules_available.append(mos.CREATE)
|
||||||
except (AttributeError, ModuleNotFoundError):
|
except (AttributeError, ModuleNotFoundError, RuntimeError):
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Error importing SMS module {module}: {e}")
|
logger.error("Error importing SMS module {module}: {e}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue