{% extends "misago/admin/conf/form.html" %}
{% load i18n misago_admin_form %}


{% block form-body %}
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Basic settings" context "admin oauth2 settings form" %}</legend>

    {% form_row form.enable_oauth2_client %}
    {% form_row form.oauth2_provider %}
    {% form_row form.oauth2_client_id %}
    {% form_row form.oauth2_client_secret %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Initializing login" context "admin oauth2 settings form" %}</legend>

    {% form_row form.oauth2_login_url %}
    {% form_row form.oauth2_scopes %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Retrieving access token" context "admin oauth2 settings form" %}</legend>

    {% form_row form.oauth2_token_url %}
    {% form_row form.oauth2_token_extra_headers %}
    {% form_row form.oauth2_json_token_path %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Retrieving user data" context "admin oauth2 settings form" %}</legend>

    {% form_row form.oauth2_user_url %}
    {% form_row form.oauth2_user_method %}
    {% form_row form.oauth2_user_token_location %}
    {% form_row form.oauth2_user_token_name %}
    {% form_row form.oauth2_user_extra_headers %}
    
  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "New user sign-ons" context "admin oauth2 settings form" %}</legend>

    {% form_row form.oauth2_send_welcome_email %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "User JSON mappings" context "admin oauth2 settings form" %}</legend>

    <p>
      {% blocktrans trimmed context "admin oauth2 settings form" %}
        Path to value is a key under which it can be found in the JSON with user data returned by the provider. If this key is nested under other key, use full path and separate keys with periods ("<code>.</code>").
      {% endblocktrans %}
    </p>
    <p>
      {% trans "For example, for given JSON with user data:" context "admin oauth2 settings form" %}
    </p>
    <p>
      <code>
        {<br />
          &nbsp;&nbsp;"id": "380422",<br />
          &nbsp;&nbsp;"name": "Bob",<br />
          &nbsp;&nbsp;"email": "bob@example.com",<br />
          &nbsp;&nbsp;"picture": {<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"url": "http://exmaple.com/users/avatars/f7s6a8d68sa68sa.jpg"<br />
          &nbsp;&nbsp;}<br />
        }
      </code>
    </p>
    <p>
      {% blocktrans trimmed context "admin oauth2 settings form" %}
        Those paths should be used:
      {% endblocktrans %}
    </p>
    <ul class="list-unstyled">
      <li>{% trans "User ID" context "admin oauth2 settings form" %}: <code>id</code></li>
      <li>{% trans "User name" context "admin oauth2 settings form" %}: <code>name</code></li>
      <li>{% trans "User e-mail" context "admin oauth2 settings form" %}: <code>email</code></li>
      <li>{% trans "User avatar" context "admin oauth2 settings form" %}: <code>picture.url</code></li>
    </ul>

    {% form_row form.oauth2_json_id_path %}
    {% form_row form.oauth2_json_name_path %}
    {% form_row form.oauth2_json_email_path %}
    {% form_row form.oauth2_json_avatar_path %}

  </fieldset>
</div>
{% endblock form-body %}