{% extends 'layout.twig' %}
{% block body %}
    {% include 'nav.twig' %}
    <h1 class="center">Reset Password</h1>
    {% if code_sent == "true" %}
        <form class="container" action="resetpassword.php" method="POST">
            <div class="form-group" >
                {% if code|length == 0%}<label for="exampleInputEmail1">Enter Temporary Code</label>{% endif %}
                <input  name="code" {% if code|length > 0%} type="hidden" {% endif%} class="form-control" value="{{ code }}">
                <label for="exampleInputEmail1">Enter Username or Email</label>
                <input name="username"  class="form-control" value="{{ username }}">
                <label for="exampleInputEmail1">Enter new password</label>
                <input required type="password" class="form-control" name="password_r" >
                <label for="exampleInputEmail1">Re-enter new password</label>
                <input required type="password" class="form-control" name="confirm_password" >
            </div>
            <a href="resetpassword.php">Didn't receive it? Click here to try again</a><br>
            <button type="submit" class="btn btn-primary">Reset Password</button>
        </form>
    {% else %}
    <form class="container" action="index.php" method="POST">
        <div class="form-group" >
            <input type="hidden" name="resetpasswordrequest">
            <label for="exampleInputEmail1">Email address or Username</label>
            <input required type="text" class="form-control"  name="username" aria-describedby="emailHelp" value="{{ username }}" placeholder="Enter email">
        </div>
        <button type="submit" class="btn btn-primary">Reset Password</button>
    </form>
    {% endif %}

{% endblock %}