Administrators can remove two factor authentication
This commit is contained in:
		@@ -68,6 +68,25 @@
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <!-- Two-Factor authentication -->
 | 
			
		||||
    <input type="hidden" name="two_factor" value=""/>
 | 
			
		||||
    {% if u.has_two_factor() %}
 | 
			
		||||
    <fieldset class="form-group">
 | 
			
		||||
        <legend class="mt-4">Two factor authentication</legend>
 | 
			
		||||
        <strong>If you uncheck a factor, it will be DELETED</strong>
 | 
			
		||||
        {% for f in u.two_factor.as_deref().unwrap_or_default() %}
 | 
			
		||||
        <div class="form-check">
 | 
			
		||||
            <label class="form-check-label">
 | 
			
		||||
                <input type="checkbox" class="form-check-input two-fact-checkbox"
 | 
			
		||||
                       value="{{ f.id.0 }}"
 | 
			
		||||
                       checked=""/>
 | 
			
		||||
                {{ f.name }} ({{ f.type_str() }})
 | 
			
		||||
            </label>
 | 
			
		||||
        </div>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
    </fieldset>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 | 
			
		||||
    <!-- Granted clients -->
 | 
			
		||||
    <fieldset class="form-group">
 | 
			
		||||
        <legend class="mt-4">Granted clients</legend>
 | 
			
		||||
@@ -161,11 +180,15 @@
 | 
			
		||||
 | 
			
		||||
        document.querySelector("input[name=granted_clients]").value = authorized_clients;
 | 
			
		||||
 | 
			
		||||
        const factors_to_keep = [...document.querySelectorAll(".two-fact-checkbox")]
 | 
			
		||||
            .filter(e => e.checked)
 | 
			
		||||
            .map(e => e.value)
 | 
			
		||||
            .join(";")
 | 
			
		||||
 | 
			
		||||
        document.querySelector("input[name=two_factor]").value = factors_to_keep;
 | 
			
		||||
 | 
			
		||||
        form.submit();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
{% endblock content %}
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
    </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
    {% for f in user.second_factors.as_deref().unwrap_or_default() %}
 | 
			
		||||
    {% for f in user.two_factor.as_deref().unwrap_or_default() %}
 | 
			
		||||
    <tr id="factor-{{ f.id.0 }}">
 | 
			
		||||
        <td>{{ f.type_str() }}</td>
 | 
			
		||||
        <td>{{ f.name }}</td>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user