<!DOCTYPE html>
<html lang="es">
    <%- include('../partials/head'); %>
    <body>
        <div class="container">
            <%- include('../partials/header'); %>
            <div class="bg-image p-5">
                <div class="bg-dark bg-opacity-75 w-75 mx-auto p-5">
                    <h1 class="font-brand text-center mb-4 text-light">Cambiar contraseña</h1>
                    <hr class="h-line bg-blue w-50 mx-auto mb-5">
                    <form action="/users/resetPassword?_method=PUT" method="POST">
                        <input type="hidden" value="_method" value="PUT">
                        <div class="p-5 pt-0">
                            <% if (user == null) { %>
                                <div class="form-floating mb-3">
                                    <input type="text" class="form-control" id="username" name="username" placeholder="Nombre de usuario" required minlength="2" autofocus>
                                    <label for="username">Nombre de usuario (acceso)</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input type="email" class="form-control" id="email" name="email" placeholder="Correo electrónico" required>
                                    <label for="email">Email</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="Contraseña" required minlength="6">
                                    <label for="newPassword">Nueva contraseña de acceso</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input type="password" class="form-control" id="password" name="password" placeholder="Confirmar contraseña" required minlength="6">
                                    <label for="password">Confirmar nueva contraseña</label>
                                </div>
                                <span id="error" class="text-danger"></span>
                            <%} else { %>
                                <div class="form-floating mb-3">
                                    <input type="password" class="form-control" id="oldPassword" name="oldPassword" placeholder="Contraseña antigua" required>
                                    <label for="oldPassword">Antigua contraseña de acceso</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="Contraseña nueva" required minlength="6">
                                    <label for="newPassword">Nueva contraseña de acceso</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input type="password" class="form-control" id="password" name="password" placeholder="Confirmar contraseña" required minlength="6">
                                    <label for="password">Confirmar nueva contraseña</label>
                                </div>
                                <span id="error" class="text-danger"></span>
                            <% } %>      
                        </div>
                        <div class="text-center w-100">
                            <a href="/home" class="btn btn-secondary">
                                <i class="bi bi-x-lg"></i> 
                                Cancelar
                            </a>
                            <button type="submit" class="btn btn-success bg-blue text-light"><i class="bi bi-check-lg"></i> Cambiar contraseña</button>
                        </div>
                    </form>
                </div>
            </div>
            <%- include('../partials/footer'); %>
        </div>
    </body>
</html>    