expephalon-playsms/core/helpers/otp.py

18 lines
496 B
Python
Raw Normal View History

from core.modules.otp import providers
def get_user_otps(user):
active_providers = {}
for name, provider in providers.items():
if provider().active_for_user(user):
active_providers[name] = provider
return active_providers
def get_otp_by_name(name):
for pname, provider in providers.items():
if pname == name:
return provider
def get_otp_choices(user):
return [(name, provider) for name, provider in get_user_otps(user).items()]