{% extends "layout.html" %}
{% block content %}
<section class="row">
  <div class="col-md-8 offset-md-2">
    <h2>
      Share "{{ secret.name or secret.uuid }}" with another user
    </h2>
    <dl>
      {% if secret.name %}
      <dt>UUID</dt>
      <dd>{{ secret.uuid }}</dd>
      {% endif %}
      <dt>Type</dt>
      <dd>{{ secret.secret_type.pretty_name }}</dd>
      <dt>Created</dt>
      <dd>{{ secret.created | date }}</dd>
      <dt>Last used</dt>
      <dd>{{ secret.updated | date }}</dd>
      {% if secret.secret_type.value == "plaintext_file" %}
      <dt>File</dt>
      <dd>{{ secret.path }} (<i>{{ '%03o' % secret.mode }}</i> mode)</dd>
      {% endif %}
    <dl>
    <div class="alert alert-danger">
      {{icon('exclamation-triangle')}}
      <strong>
        This action cannot be undone!
      </strong>
      The secret will be copied to the target user's account and cannot be
      unshared. The target user will be able to read and use the secret without
      any limitations. If this is done in error, you must revoke the rights
      associated with the secret and provision a new secret (e.g. by generating
      a new SSH key and revoking the old one).
    </div>
    <form method="POST">
      {{csrf_token()}}
      <div class="form-group">
        <label for="username">Username</label>
        <input
           type="text"
           name="username"
           id="username"
           value="{{ username }}"
           class="form-control {{valid.cls("username")}}"
           required
           autocomplete="username" />
        {{valid.summary("username")}}
      </div>

      {{valid.summary()}}

      <button type="submit" class="btn btn-danger">
        Permanently share "{{ secret.name or secret.uuid }}" with this user {{icon('caret-right')}}
      </button>
      <a href="/secrets" class="btn btn-default">
        Cancel {{icon('caret-right')}}
      </a>
    </form>
  </div>
</section>
{% endblock %}
