mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-12 09:17:56 +03:00
Adde "custom html" support for MFA input code page
This commit is contained in:
parent
0496117fc1
commit
f5d2776478
@ -119,6 +119,13 @@ class MFA(Module):
|
||||
"""
|
||||
return 'MFA Code'
|
||||
|
||||
def html(self, request: 'ExtendedHttpRequest') -> str:
|
||||
"""
|
||||
This method will be invoked from the MFA form, to know the HTML that will be presented
|
||||
to the user below the MFA code form.
|
||||
"""
|
||||
return ''
|
||||
|
||||
def validity(self) -> int:
|
||||
"""
|
||||
This method will be invoked from the MFA form, to know the validity in secods
|
||||
|
@ -6,7 +6,7 @@ import ssl
|
||||
import typing
|
||||
import logging
|
||||
|
||||
from django.utils.translation import gettext_noop as _
|
||||
from django.utils.translation import gettext_noop as _, gettext
|
||||
|
||||
from uds import models
|
||||
from uds.core import mfas
|
||||
@ -150,6 +150,9 @@ class EmailMFA(mfas.MFA):
|
||||
# now check from email and to email
|
||||
self.fromEmail.value = validators.validateEmail(self.fromEmail.value)
|
||||
|
||||
def html(self, request: 'ExtendedHttpRequest') -> str:
|
||||
return gettext('Check your mail. You will receive an email with the verification code')
|
||||
|
||||
@classmethod
|
||||
def initClassGui(cls) -> None:
|
||||
# Populate the networks list
|
||||
|
@ -318,6 +318,9 @@ class SMSMFA(mfas.MFA):
|
||||
def label(self) -> str:
|
||||
return gettext('MFA Code')
|
||||
|
||||
def html(self, request: 'ExtendedHttpRequest') -> str:
|
||||
return gettext('Check your phone. You will receive an SMS with the verification code')
|
||||
|
||||
def sendCode(self, request: 'ExtendedHttpRequest', userId: str, username: str, identifier: str, code: str) -> mfas.MFA.RESULT:
|
||||
logger.debug(
|
||||
'Sending SMS code "%s" for user %s (userId="%s", identifier="%s")',
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -286,10 +286,14 @@ def mfa(request: ExtendedHttpRequest) -> HttpResponse:
|
||||
else:
|
||||
remember_device = _('{} hours').format(mfaProvider.remember_device)
|
||||
|
||||
# Html from MFA provider
|
||||
mfaHtml = mfaInstance.html(request)
|
||||
|
||||
# Redirect to index, but with MFA data
|
||||
request.session['mfa'] = {
|
||||
'label': label or _('MFA Code'),
|
||||
'validity': validity if validity >= 0 else 0,
|
||||
'remember_device': remember_device,
|
||||
'html': mfaHtml,
|
||||
}
|
||||
return index(request) # Render index with MFA data
|
||||
|
Loading…
Reference in New Issue
Block a user