{% extends "layout2.html" %} {% load i18n %} {% load static %} {% block css_include %} {% endblock %} {% block js_include %} {% endblock %} {% block content %}
{% csrf_token %}
{% if form.non_field_errors %}
{# Print form errors correctly #}

Form errors

{{ form.non_field_errors|safe }}
{% endif %}

 {% translate "OpenID Repository edition" %}

{{form.name}} {{form.name.errors|safe}}
{{form.provider}} {{form.provider.errors|safe}}
{{form.provider_url}} {{form.provider_url.errors|safe}}
{{form.client_id}} {{form.client_id.errors|safe}}
{{form.client_secret}} {{form.client_secret.errors|safe}}
{{form.scopes}} {{form.scopes.errors|safe}}
{{form.user_scope}} {{form.user_scope.errors|safe}}
{{form.enable_jwt}} {{form.enable_jwt.errors|safe}}
{{form.jwt_signature_type}} {{form.jwt_signature_type.errors|safe}}
{{form.jwt_key}} {{form.jwt_key.errors|safe}}
{{form.jwt_validate_audience}} {{form.jwt_validate_audience.errors|safe}}
{{form.use_proxy}} {{form.use_proxy.errors|safe}}
{{form.verify_certificate}} {{form.verify_certificate.errors|safe}}
{% endblock %} {% block jquery_code %} if (!String.prototype.endsWith) { String.prototype.endsWith = function(searchString, position) { var subjectString = this.toString(); if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { position = subjectString.length; } position -= searchString.length; var lastIndex = subjectString.lastIndexOf(searchString, position); return lastIndex !== -1 && lastIndex === position; }; } /* Initialize select2 objects */ $('.select2').select2(); /* Switchery mandatory code */ var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch')); elems.forEach(function(html) { var switchery = new Switchery(html, { 'color': '#FA9834', }); }); /* Show fields depending on chosen provider */ function handle_provider(e) { var provider = $('#id_provider').val(); $('.provider-specific').hide(); $('.provider-'+provider).show(); } $('#id_provider').on("change", handle_provider); handle_provider(); function get_data(){ var data = { name: "test", provider: $('#id_provider').val(), provider_url: $('#id_provider_url').val(), client_id: $('#id_client_id').val(), client_secret: $('#id_client_secret').val(), scopes: $('#id_scopes').val(), use_proxy: $('#id_use_proxy').is(':checked'), verify_certificate: $('#id_verify_certificate').is(':checked'), }; var type_ = $('#id_provider').val(); console.log(type_) $("." + type_ + " input").each(function(){ var name = $(this).attr('name'); switch($(this).attr('type')){ case "checkbox": data[name] = $(this).is(':checked'); break; case "text": data[name] = $(this).val(); break; case "password": data[name] = $(this).val(); break; } }) $("." + type_ + " textarea").each(function(){ var name = $(this).attr('name'); data[name] = $(this).val(); }) $("." + type_ + " select").each(function(){ var name = $(this).attr('name'); data[name] = $(this).val(); }) return data; } $('#test_provider').unbind('click'); $('#test_provider').on('click', function(){ PNotify.removeAll(); var btn = this; var txt = $(btn).html(); $(btn).html(''); $(btn).prop('disabled', true); var data = get_data(); $.post( "{% url 'authentication.openid.test_provider' %}", data, function(response){ $(btn).prop('disabled', false); $(btn).html(txt); handle_form_errors(response); if (!check_json_error(response)){ $('#provider_has_been_tested').val('0'); return; } var data = response.data; $('#provider_has_been_tested').val('1'); $('#modal-test-openid-body').html('
' + JSON.stringify(data, null, 4) + "
"); $('#modal-test-openid').modal('show'); } ).fail(function(response){ notify('error', response.status, response.responseText) $(btn).prop('disabled', false); $(btn).html(txt); }) }) /* Show jwt class if enable_jwt is True */ $('#id_enable_jwt').on('change', function(e) { if ( $(this).is(':checked') ) $('.jwt').show(); else $('.jwt').hide(); }).trigger('change'); function handle_form_errors(data){ if (typeof(data['form_errors']) !== 'undefined'){ $('.errorlist').remove(); $.each(data['form_errors'], function(field_name, error_list){ field_selector = $('#id_'+field_name); var ul = $('