<!--

    Tigase HTTP API component - Tigase HTTP API component
    Copyright (C) 2013 Tigase, Inc. (office@tigase.com)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, version 3 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program. Look for COPYING file in the top folder.
    If not, see http://www.gnu.org/licenses/.

-->
${ util.include('header', [title:'Password reset']) }
<div class="col-sm-6" style="float: none; margin: 0 auto;">
<% if (result.error) { %>
    <div class="panel panel-danger">
        <div class="panel-heading panel-xs">
            <h4>Password reset failure.</h4>
        </div>
        <div class="panel-body">
            <h4>Error: ${result?.error}</h4>
        </div>
    </div>
<% } else if (!result.errors && result.jid) { %>
    <div class="panel panel-success">
        <div class="panel-heading panel-xs">
            <h4>Check your email</h4>
        </div>
        <div class="panel-body">
            <h5>Email was sent to <strong>${result.email}</strong>. Click the link in the email to reset password for account <strong>${result.jid}</strong>.</h5>
            <h5>If you don't see the email, check other mail folders, like junk and spam.</h5>
        </div>
    </div>
<% } else { %>
    <form method="POST" class="form-horizontal">
        <div class="panel panel-default">
            <div class="panel-heading panel-xs">
                <h4>Reset account password</h4>
            </div>
            <div class="panel-body">
                <h5>Please fill out this form to reset password for an account.</h5>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for='jid'>JID:</label>
                    <div class="col-sm-10">
                        <input class="form-control" type='text' size='90' name='jid' value="${result.jid ?: ''}" required/>
                        <small class="text-muted">XMPP account address</small>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for='email'>Email:</label>
                    <div class="col-sm-10">
                        <input class="form-control" type='text' size='90' name='email' value="${result.email ?: ''}" required/>
                        <small class="text-muted">Email used during registration</small>
                    </div>
                </div>
                <% if (result.captcha) { %>
                    <input name="id" type="hidden" value="${result.captcha.id}" />
                    <input name="captcha-query" type="hidden" value="${result.captcha.captcha}" />
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for='captcha'>${result.captcha.captcha} = </label>
                        <div class="col-sm-10">
                            <input class="form-control" type='text' size='90' name='captcha' value="" required/>
                        </div>
                    </div>
                <% } %>
            </div>
            <% if (result.errors) { %>
            <div class="alert alert-danger" role="alert" style="margin: 0px">
                <h4>Error</h4>
                <% result.errors.each { %><h5>${it}</h5><% } %>
            </div>
            <% } %>
        </div>

        <button class="btn btn-primary" type="submit">Reset password</button>
    </form>
<% } %>
</div>
${ util.include('footer') }