{{ include ("Auth/Header.html") }}
<div id="page-container" class="main-content-boxed">
    <!-- Main Container -->
    <main id="main-container">
        <!-- Page Content -->

        <div class="row mx-0 justify-content-center hero-static align-items-center">
            <div class="col-xl-4" style="width: 540px;">
                <!-- Sign In Form -->
                <form id="login-form">
                    <div class="block block-themed block-rounded block-fx-shadow">
                        <div class="block-header bg-gd-dusk">
                            <h3 class="block-title">{{ site.title }}</h3>
                        </div>
                        <div class="block-content" id="form-input">
                            <div class="form-floating mb-4">
                                <input type="text" class="form-control" placeholder="Email" id="login-email"
                                       name="email">
                                <label class="form-label" for="login-email">Email</label>
                            </div>
                            <div class="form-floating mb-4">
                                <input type="password" class="form-control" id="login-password" name="password"
                                       placeholder="{{ i18n("请输入你的密码")|raw }}..">
                                <label class="form-label" for="login-password">{{ i18n("密码")|raw }}</label>
                            </div>

                            <div class="row" id="form-button">
                                <div class="col-sm-6 d-sm-flex align-items-center push">
                                    <a class="fs-sm fw-medium link-fx text-muted me-2 mb-1 d-inline-block"
                                       href="javascript:layer.msg('网站根目录通过执行SSH命令重置密码：【mcy kit.reset 新密码】');">
                                        {{ i18n("忘记密码")|raw }}?
                                    </a>
                                </div>
                                <div class="col-sm-6 text-sm-end push">
                                    <button type="button" class="btn btn-lg btn-alt-primary fw-medium button-login">
                                        {{ i18n("登入")|raw }}
                                    </button>
                                </div>
                            </div>


                        </div>
                    </div>
                </form>
                <!-- END Sign In Form -->
            </div>
        </div>

        <!-- END Page Content -->
    </main>
    <!-- END Main Container -->
</div>
<!-- END Page Container -->

<script>

    window.onload = function () {
        $('.button-login').click(function () {
            let data = util.arrayToObject($('#login-form').serializeArray());
            data.token = util.getClientToken();
            util.post("/admin", data, res => {
                localStorage.setItem("manage_token", data.token);
                window.location.href = util.getParam("goto") !== null ? decodeURIComponent(util.getParam("goto")) : "/admin/dashboard";
            });
        });

        $(document).keydown(function (event) {
            if (event.key === 'Enter') {
                $(".button-login").click();
            }
        });
    }
</script>

{{ hook(env(true), point("ADMIN_AUTH_LOGIN_BODY")) }}
{{ include ("Auth/Footer.html") }}