<% include header %>

<!-- login tester -->

<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <div class="card">
                <div class="row">
                    <div class="col-md-12" style="text-align: center;">
                        <img width="128" height="128" src="<%= applicationLogo %>?<%= Math.random() %>"/>
                        <h1><small>Login to</small> <%= applicationName %></h1>
                        <br/>
                    </div>
                </div>
                <br/>
            <% if (error) { %>
                <div class="row">
                    <div class="col-md-12">
                        <h4 class="has-error"><%= error %></h4>
                    </div>
                </div>
            <% } %>
                <div class="row">
                    <div class="col-md-12">
                        <form id="loginForm" action="" method="post">
                            <input type="hidden" name="_csrf" value="<%= csrf %>"/>
                            <div class="form-group">
                                <label class="control-label" for="inputUsername">Username or Email</label>
                                <input type="text" class="form-control" id="inputUsername" name="username" value="<%= username %>" autofocus required>
                            </div>
                            <div class="form-group">
                                <label class="control-label" for="inputPassword">Password</label>
                                <input type="password" class="form-control" name="password" id="inputPassword" value="<%= password %>" required>
                            </div>
                            <input class="btn btn-primary btn-outline pull-right" type="submit" value="Sign in"/>
                        </form>
                        <a href="/api/v1/session/password/resetRequest.html">Reset your password</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

(function () {
    'use strict';

    var search = window.location.search.slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {});

    document.getElementById('loginForm').action = '/api/v1/session/login?returnTo=' + search.returnTo;
})();

</script>

<% include footer %>
