{{ template "header.html" }}

<div class="panel">
  <h2 class="heading">Create Your Account</h2>

  {{ if .Error }}
  <div class="error-box">{{ .Message }}</div>
  {{ else if .RemoteExists }}
     {{ with .RemoteExists }}
     <div class="instruction-block">
       This account is already registered.
       If you'd like to login with that account, click here:
     </div>
      <div>
        <a href="{{ .Login }}" target="_self">
          <button class="btn btn-provider">
            <span class="btn-text">Login</span>
          </button>
        </a>
      </div>
      <div class="instruction-block">
        If you would like to register with a different account, click here:
      </div>
      <div>
        <a href="{{ .Register }}" target="_self">
          <button class="btn btn-provider">
            <span class="btn-text">Register</span>
          </button>
        </a>
      </div>
     {{ end }}

  {{ else }}

    <form id="registerForm" method="POST" action="/register">

      <div class="form-row">
        <div class="input-desc">
          <label for="email">Email Address</label>
        </div>
        <input id="email" class="input-box" type="text" name="email" required placeholder="email" value="{{.Email}}" autofocus />
        {{ range $fe := .FormErrors }}
          {{ if eq $fe.Field "email" }}
          <div class="error-box-field">{{ $fe.Error }}</div>
          {{ end }}
        {{ end }}
      </div>

      {{ if .Local }}
      <div class="form-row">
        <div class="input-desc">
          <label for="password">Password</label>
        </div>
        <input minlength="6" required id="password" name="password" type="password" class="input-box" value="{{.Password}}"/>
        {{ range $fe := .FormErrors }}
          {{ if eq $fe.Field "password" }}
          <div class="error-box-field">{{ $fe.Error }}</div>
          {{ end }}
        {{ end }}
      </div>
      {{ end }}

      <button type="submit" class="btn btn-primary">Create Account</button>
      <input type="hidden" name="code" value="{{.Code}}"/>
      <input type="hidden" name="validate" value="1"/>
    </form>

  {{ end }}

</div>

{{ template "footer.html" }}
