{%extends "base.html"%}

{%block title%}gn-auth: Verify Email{%endblock%}

{%block pagetitle%}Verify Email{%endblock%}

{%block content%}
{{flash_messages()}}

<div class="container-fluid">
  <div class="row"><h1>Verify Your E-Mail</h1></div>

  {%if token_found:%}
  <div class="row">
    <form id="frm-email-verification" method="POST"
          action="{{url_for('oauth2.users.verify_user')}}">
      <legend>Email Verification</legend>

      <p>If you are seeing this, your account needs to be verified.</p>

      <p>An email with a verification token has already been sent to the address
        associated with this account (<em>{{email}}</em>). Please provide that
        verification token below and click the "<em>Verify Email Address</em>"
        button to verify your account.</p>

      <input type="hidden" name="email" value="{{email}}" />
      <input type="hidden" name="response_type" value="{{response_type}}" />
      <input type="hidden" name="client_id" value="{{client_id}}" />
      <input type="hidden" name="redirect_uri" value="{{redirect_uri}}" />

      <fieldset class="form-group">
        <label for="txt-verification-code" class="form-label">
          Verification Code</label>
        <input id="txt-verification-code" name="verificationcode" type="text"
               required="required" class="form-control"
               placeholder="Enter your verification code here." />
      </fieldset>

      <fieldset>
        <input type="submit" value="Verify Email Address" class="btn btn-primary" />
      </fieldset>
    </form>
  </div>
  {%else:%}
  <div class="row">
    <form id="frm-send-verification-code" method="POST"
          action="{{url_for('oauth2.users.send_verification_code')}}">
      <legend>Send Verification Code</legend>

      <p>Provide your password below, and we will send you a verification password
        to your email.</p>
      <p>You are seeing this page because:</p>
      <ol type="a">
        <li>You already had an existing account.<br />
          In this case, you will need to request a verification code by
          providing your email below and clicking the
          "<em>Send Verification Code</em>" button.<br />
          We will send you an email with both:
          <ol type="1">
            <li>a link you can click to verify your email, <strong>and</strong>
            </li>
            <li>a token to copy and paste if you choose not to follow the link.
            </li>
          </ol>
        </li>
        <li>You registered your account recently, but did not verify it within the
          time period allocated for that. In this case, simply request a new
          verification email below, and follow the link, or copy and paste the
          token in the email we send you.</li>
      </ol>

      <input type="hidden" name="user_email" value="{{email}}" />
      <input type="hidden" name="response_type" value="{{response_type}}" />
      <input type="hidden" name="client_id" value="{{client_id}}" />
      <input type="hidden" name="redirect_uri" value="{{redirect_uri}}" />

      <fieldset class="form-group">
        <label class="form-label">Email</label>
        <label class="form-control">{{email}}</label>
      </fieldset>

      <fieldset class="form-group">
        <label for="txt-password" class="form-label">Password</label>
        <input id="txt-password" name="user_password" type="password"
               placeholder="Enter your GeneNetwork password"
               class="form-control" />
      </fieldset>
      <input type="submit" value="Send Verification Code" class="btn btn-danger" />
    </form>
  </div>
  {%endif%}
</div>
{%endblock%}