expephalon-kumisms/core/helpers/otp.py
Klaus-Uwe Mitterer 7708128255 Finally got all the OTP stuff working
Finalized dbsettings views
Easter egg for missing backend pages
2020-04-15 22:19:03 +02:00

25 lines
No EOL
667 B
Python

from core.models import OTPUser
from core.modules.otp import providers
def get_user_otps(user):
try:
all_otps = OTPUser.objects.filter(user=user)
except:
return {}
user_providers = [otp.provider for otp in all_otps]
active_providers = {}
for name, provider in providers.items():
if name in user_providers:
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()]