mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	two_factor: Add templates for 2-factor-auth setup.
Note from Tim: We'll likely need to do some work on the strings in these before translating, so I removed some translation tags.
This commit is contained in:
		
							
								
								
									
										42
									
								
								templates/two_factor/_wizard_forms.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								templates/two_factor/_wizard_forms.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					{% if wizard.steps.current == 'token' %}
 | 
				
			||||||
 | 
					    {% if device.method == 'call' %}
 | 
				
			||||||
 | 
					    <p>We are calling your phone right now, please enter the
 | 
				
			||||||
 | 
					    digits you hear.</p>
 | 
				
			||||||
 | 
					    {% elif device.method == 'sms' %}
 | 
				
			||||||
 | 
					    <p>We sent you a text message, please enter the token in the text message.</p>
 | 
				
			||||||
 | 
					    {% else %}
 | 
				
			||||||
 | 
					    <p>Please enter the 6-digit number from your token generator.</p>
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
 | 
					{% elif wizard.steps.current == 'backup' %}
 | 
				
			||||||
 | 
					    <p>
 | 
				
			||||||
 | 
					        Use this form for entering backup tokens for logging in.
 | 
				
			||||||
 | 
					        These tokens have been generated for you to print and keep safe. Please
 | 
				
			||||||
 | 
					        enter one of these backup tokens to login to your account.
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% for field in wizard.form %}
 | 
				
			||||||
 | 
					<div class="input-box no-validation">
 | 
				
			||||||
 | 
					    {{ field }}
 | 
				
			||||||
 | 
					    <label for="{{ field.id_for_label }}">{{ field.label }}</label>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					{% endfor %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% if other_devices %}
 | 
				
			||||||
 | 
					<p>{{ _("Or, alternatively, use one of your backup phones:") }}</p>
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					    {% for other in other_devices %}
 | 
				
			||||||
 | 
					    <button name="challenge_device" value="{{ other.persistent_id }}"
 | 
				
			||||||
 | 
					      class="btn btn-default btn-block" type="submit">
 | 
				
			||||||
 | 
					        {{ other|device_action }}
 | 
				
			||||||
 | 
					    </button>
 | 
				
			||||||
 | 
					    {% endfor %}
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					{% if backup_tokens %}
 | 
				
			||||||
 | 
					<p>{{ _("As a last resort, you can use a backup token:") }}</p>
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					    <button name="wizard_goto_step" type="submit" value="backup"
 | 
				
			||||||
 | 
					      class="btn btn-default btn-block">{{ _("Use backup token") }}</button>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
@@ -69,9 +69,13 @@
 | 
				
			|||||||
                                <form name="login_form" id="login_form" method="post" class="login-form"
 | 
					                                <form name="login_form" id="login_form" method="post" class="login-form"
 | 
				
			||||||
                                  action="{{ url('django.contrib.auth.views.login') }}?next={{ next }}">
 | 
					                                  action="{{ url('django.contrib.auth.views.login') }}?next={{ next }}">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    {% if two_factor_authentication_enabled %}
 | 
				
			||||||
 | 
					                                    {{ wizard.management_form }}
 | 
				
			||||||
 | 
					                                    {% endif %}
 | 
				
			||||||
                                    {{ csrf_input }}
 | 
					                                    {{ csrf_input }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    <!-- .no-validation is for removing the red star in CSS -->
 | 
					                                    <!-- .no-validation is for removing the red star in CSS -->
 | 
				
			||||||
 | 
					                                    {% if not two_factor_authentication_enabled or wizard.steps.current == 'auth' %}
 | 
				
			||||||
                                    <div class="input-box no-validation">
 | 
					                                    <div class="input-box no-validation">
 | 
				
			||||||
                                        <input id="id_username" type="{% if not require_email_format_usernames %}text{% else %}email{% endif %}"
 | 
					                                        <input id="id_username" type="{% if not require_email_format_usernames %}text{% else %}email{% endif %}"
 | 
				
			||||||
                                          name="username" class="{% if require_email_format_usernames %}email {% endif %}required"
 | 
					                                          name="username" class="{% if require_email_format_usernames %}email {% endif %}required"
 | 
				
			||||||
@@ -92,6 +96,9 @@
 | 
				
			|||||||
                                        <input id="id_password" name="password" class="required" type="password" required />
 | 
					                                        <input id="id_password" name="password" class="required" type="password" required />
 | 
				
			||||||
                                        <label for="id_password" class="control-label">{{ _('Password') }}</label>
 | 
					                                        <label for="id_password" class="control-label">{{ _('Password') }}</label>
 | 
				
			||||||
                                    </div>
 | 
					                                    </div>
 | 
				
			||||||
 | 
					                                    {% else %}
 | 
				
			||||||
 | 
					                                    {% include "two_factor/_wizard_forms.html" %}
 | 
				
			||||||
 | 
					                                    {% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    {% if form.errors %}
 | 
					                                    {% if form.errors %}
 | 
				
			||||||
                                    <div class="alert alert-error">
 | 
					                                    <div class="alert alert-error">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,6 +131,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
 | 
				
			|||||||
        'password_min_length': settings.PASSWORD_MIN_LENGTH,
 | 
					        'password_min_length': settings.PASSWORD_MIN_LENGTH,
 | 
				
			||||||
        'password_min_guesses': settings.PASSWORD_MIN_GUESSES,
 | 
					        'password_min_guesses': settings.PASSWORD_MIN_GUESSES,
 | 
				
			||||||
        'jitsi_server_url': settings.JITSI_SERVER_URL,
 | 
					        'jitsi_server_url': settings.JITSI_SERVER_URL,
 | 
				
			||||||
 | 
					        'two_factor_authentication_enabled': settings.TWO_FACTOR_AUTHENTICATION_ENABLED,
 | 
				
			||||||
        'zulip_version': ZULIP_VERSION,
 | 
					        'zulip_version': ZULIP_VERSION,
 | 
				
			||||||
        'user_is_authenticated': user_is_authenticated,
 | 
					        'user_is_authenticated': user_is_authenticated,
 | 
				
			||||||
        'settings_path': settings_path,
 | 
					        'settings_path': settings_path,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -117,6 +117,7 @@ class TemplateTestCase(ZulipTestCase):
 | 
				
			|||||||
            'zerver/handlebars_compilation_failed.html',
 | 
					            'zerver/handlebars_compilation_failed.html',
 | 
				
			||||||
            'zerver/portico-header.html',
 | 
					            'zerver/portico-header.html',
 | 
				
			||||||
            'zerver/deprecation_notice.html',
 | 
					            'zerver/deprecation_notice.html',
 | 
				
			||||||
 | 
					            'two_factor/_wizard_forms.html',
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        integrations_regexp = re.compile('zerver/integrations/.*.html')
 | 
					        integrations_regexp = re.compile('zerver/integrations/.*.html')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ from django.template.defaultfilters import slugify, pluralize
 | 
				
			|||||||
from django.urls import reverse
 | 
					from django.urls import reverse
 | 
				
			||||||
from django.utils import translation
 | 
					from django.utils import translation
 | 
				
			||||||
from jinja2 import Environment
 | 
					from jinja2 import Environment
 | 
				
			||||||
 | 
					from two_factor.templatetags.two_factor import device_action
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .compressors import minified_js
 | 
					from .compressors import minified_js
 | 
				
			||||||
from zerver.templatetags.app_filters import display_list, render_markdown_path
 | 
					from zerver.templatetags.app_filters import display_list, render_markdown_path
 | 
				
			||||||
@@ -25,5 +26,6 @@ def environment(**options: Any) -> Environment:
 | 
				
			|||||||
    env.filters['slugify'] = slugify
 | 
					    env.filters['slugify'] = slugify
 | 
				
			||||||
    env.filters['pluralize'] = pluralize
 | 
					    env.filters['pluralize'] = pluralize
 | 
				
			||||||
    env.filters['display_list'] = display_list
 | 
					    env.filters['display_list'] = display_list
 | 
				
			||||||
 | 
					    env.filters['device_action'] = device_action
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return env
 | 
					    return env
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user