Browse Source

tabler theme adaptation and overriding controllers

iamsaltedfish 3 years ago
parent
commit
b258b140b5

+ 3 - 1
config/.config.example.php

@@ -161,8 +161,10 @@ $_ENV['Surfboard_DefaultProfiles']  = 'default'; // Surfboard 默认配置方案
     注册设置
 */
 
+$_ENV['reg_invite_num'] = '100'; // 注册时设置邀请码的可用次数,开放注册模式下不扣减邀请码次数,仅在仅允许邀请注册的情况下扣减
+$_ENV['reg_money'] = 0; // 注册时默认的账户余额,可以设置一个数,然后引导用户在商店购买试用套餐
 $_ENV['random_group'] = '0'; // 注册时随机分配到的分组,英文半角逗号分隔
-$_ENV['enable_reg_im'] = false; // 注册时是否要求用户输入IM联系方式
+$_ENV['enable_reg_im'] = true; // 注册时是否要求用户输入IM联系方式
 $_ENV['reg_forbidden_ip'] = '127.0.0.0/8,::1/128'; // 注册时默认禁止访问IP列表,英文半角逗号分隔
 $_ENV['reg_forbidden_port'] = ''; // 注册时默认禁止访问端口列表,英文半角逗号分隔,支持端口段
 $_ENV['mu_suffix'] = 'microsoft.com'; // 单端口多用户混淆参数后缀,可以随意修改,但请保持前后端一致

+ 159 - 178
resources/views/material/auth/login.tpl

@@ -1,208 +1,189 @@
-{include file='header.tpl'}
-
-<div class="authpage">
-    <div class="container">
-        <form action="javascript:void(0);" method="POST">
-            <div class="auth-main auth-row auth-col-one">
-                <div class="auth-top auth-row">
-                    <a class="boardtop-left" href="/">
-                        <div>首 页</div>
-                    </a>
-                    <div class="auth-logo">
-                        <img src="/images/uim-logo-round.png">
+<!doctype html>
+<!--
+* Tabler - Premium and Open Source dashboard template with responsive and high quality UI.
+* @version 1.0.0-beta9
+* @link https://tabler.io
+* Copyright 2018-2022 The Tabler Authors
+* Copyright 2018-2022 codecalm.net Paweł Kuna
+* Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
+-->
+<html lang="zh">
+
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>{$config['appName']}</title>
+    <!-- CSS files -->
+    <link href="/theme/tabler/css/tabler.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-flags.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-payments.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-vendors.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/demo.min.css" rel="stylesheet" />
+    <script src="/theme/tabler/js/jquery-3.6.0.min.js"></script>
+    <script src="/theme/tabler/js/tabler.min.js"></script>
+</head>
+
+<body class=" border-top-wide border-primary d-flex flex-column">
+    <div class="page page-center">
+        <div class="container-tight py-4">
+            <div class="text-center mb-4">
+                <a href="#" class="navbar-brand navbar-brand-autodark">
+                    <img src="/images/uim-logo-round.png" height="64" alt="">
+                </a>
+            </div>
+            <div class="card card-md">
+                <div class="card-body">
+                    <h2 class="card-title text-center mb-4">登录到用户中心</h2>
+                    <div class="mb-3">
+                        <label class="form-label">注册邮箱</label>
+                        <input id="email" type="email" class="form-control">
                     </div>
-                    <a href="/auth/register" class="boardtop-right">
-                        <div>注 册</div>
-                    </a>
-                </div>
-                <div class="auth-row">
-                    <div class="form-group-label auth-row row-login">
-                        <label class="floating-label" for="email">邮箱</label>
-                        <input class="form-control maxwidth-auth" id="email" type="email" name="Email" inputmode="email" autocomplete="username">
+                    <div class="mb-2">
+                        <label class="form-label">
+                            登录密码
+                            <span class="form-label-description">
+                                <a href="/password/reset">忘记密码</a>
+                            </span>
+                        </label>
+                        <div class="input-group input-group-flat">
+                            <input id="passwd" type="password" class="form-control" autocomplete="off">
+                        </div>
                     </div>
-                </div>
-                <div class="auth-row">
-                    <div class="form-group-label auth-row row-login">
-                        <label class="floating-label" for="passwd">密码</label>
-                        <input class="form-control maxwidth-auth" id="passwd" type="password" name="Password" autocomplete="current-password">
+                    <div class="mb-2">
+                        <label class="form-label">两步认证</label>
+                        <input id="code" type="email" class="form-control" placeholder="如果没有设置两步认证可留空">
                     </div>
-                </div>
-                <div class="auth-row">
-                    <div class="form-group-label auth-row row-login">
-                        <label class="floating-label" for="code">两步验证码(未设置请忽略)</label>
-                        <input class="form-control maxwidth-auth" id="code" type="number" name="Code" inputmode="numeric" autocomplete="one-time-code">
+                    <div class="mb-2">
+                        <label class="form-check">
+                            <input id="remember_me" type="checkbox" class="form-check-input" />
+                            <span class="form-check-label">记住此设备</span>
+                        </label>
                     </div>
-                </div>
-
-                {if $geetest_html != null}
-                    <div class="form-group-label labelgeetest auth-row">
-                        <div id="embed-captcha"></div>
+                    <div class="form-footer">
+                        <button id="login-dashboard" class="btn btn-primary w-100">登录</button>
                     </div>
-                {/if}
-                {if $config['enable_login_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-                    <div class="form-group-label auth-row">
-                        <div class="row">
-                            <div align="center" class="g-recaptcha" data-sitekey="{$recaptcha_sitekey}"></div>
-                        </div>
+                </div>
+                <!-- <div class="hr-text">or</div>
+                <div class="card-body">
+                    <div class="row">
+                        <div class="col"><a href="#" class="btn btn-white w-100">
+                                <svg xmlns="http://www.w3.org/2000/svg" class="icon text-github" width="24" height="24"
+                                    viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
+                                    stroke-linecap="round" stroke-linejoin="round">
+                                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                                    <path
+                                        d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
+                                </svg>
+                                Login with Github
+                            </a></div>
+                        <div class="col"><a href="#" class="btn btn-white w-100">
+                                <svg xmlns="http://www.w3.org/2000/svg" class="icon text-twitter" width="24" height="24"
+                                    viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
+                                    stroke-linecap="round" stroke-linejoin="round">
+                                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                                    <path
+                                        d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c-.002 -.249 1.51 -2.772 1.818 -4.013z" />
+                                </svg>
+                                Login with Twitter
+                            </a></div>
                     </div>
-                {/if}
+                </div> -->
+            </div>
+            <div class="text-center text-muted mt-3">
+                还没有账户? <a href="/auth/register" tabindex="-1">点击注册</a>
+            </div>
+        </div>
+    </div>
 
-                <div class="btn-auth auth-row">
-                    <button id="login" type="submit" class="btn btn-block btn-brand waves-attach waves-light">
-                        确认登录
-                    </button>
+    <div class="modal modal-blur fade" id="success-dialog" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
+            <div class="modal-content">
+                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+                <div class="modal-status bg-success"></div>
+                <div class="modal-body text-center py-4">
+                    <svg xmlns="http://www.w3.org/2000/svg" class="icon mb-2 text-green icon-lg" width="24" height="24"
+                        viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
+                        stroke-linejoin="round">
+                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                        <circle cx="12" cy="12" r="9" />
+                        <path d="M9 12l2 2l4 -4" />
+                    </svg>
+                    <p id="success-message" class="text-muted">成功</p>
                 </div>
-                <div class="auth-help auth-row">
-                    <div class="auth-help-table auth-row">
-                        <div class="checkbox checkbox-adv">
-                            <label for="remember_me">
-                                <input class="access-hide" value="week" id="remember_me" name="remember_me"
-                                       type="checkbox">记住我</input>
-                                <span class="checkbox-circle"></span>
-                                <span class="checkbox-circle-check"></span>
-                                <span class="checkbox-circle-icon icon">done</span>
-                            </label>
+                <div class="modal-footer">
+                    <div class="w-100">
+                        <div class="row">
+                            <div class="col">
+                                <a id="success-confirm" href="#" class="btn w-100" data-bs-dismiss="modal">
+                                    好
+                                </a>
+                            </div>
                         </div>
-                        <a href="/password/reset">忘记密码?</a>
                     </div>
                 </div>
-                {if $config['enable_telegram_login'] === true}
-                    <div class="auth-bottom auth-row">
-                        <div class="tgauth">
-                            <span>Telegram</span>
-                            <button class="btn" id="calltgauth"><i class="icon icon-lg">near_me</i></button>
-                            <span>快捷登录</span>
+            </div>
+        </div>
+    </div>
+    <div class="modal modal-blur fade" id="fail-dialog" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
+            <div class="modal-content">
+                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+                <div class="modal-status bg-danger"></div>
+                <div class="modal-body text-center py-4">
+                    <svg xmlns="http://www.w3.org/2000/svg" class="icon mb-2 text-danger icon-lg" width="24" height="24"
+                        viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
+                        stroke-linejoin="round">
+                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                        <path d="M12 9v2m0 4v.01" />
+                        <path
+                            d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75" />
+                    </svg>
+                    <p id="fail-message" class="text-muted">失败</p>
+                </div>
+                <div class="modal-footer">
+                    <div class="w-100">
+                        <div class="row">
+                            <div class="col">
+                                <a href="#" class="btn btn-danger w-100" data-bs-dismiss="modal">
+                                    确认
+                                </a>
+                            </div>
                         </div>
                     </div>
-                {/if}
+                </div>
             </div>
-        </form>
-        {if $config['enable_telegram_login'] === true}
-            {include file='./telegram_modal.tpl'}
-        {/if}
+        </div>
     </div>
-</div>
-
-{include file='dialog.tpl'}
-
-{include file='footer.tpl'}
 
-{if $config['enable_telegram_login'] === true}
-    {include file='./telegram.tpl'}
-{/if}
-
-{literal}
     <script>
-        let calltgbtn = document.querySelector('#calltgauth');
-        let tgboard = document.querySelector('.card.auth-tg.cust-model');
-        if (calltgbtn && tgboard) {
-            custModal(calltgbtn, tgboard);
-        }
-    </script>
-{/literal}
-
-<script>
-    $(document).ready(function () {
-        function login() {
-            {if $geetest_html != null}
-            if (typeof validate === 'undefined' || !validate) {
-                $("#result").modal();
-                $$.getElementById('msg').innerHTML = '请滑动验证码来完成验证';
-                return;
-            }
-            {/if}
-
-            document.getElementById("login").disabled = true;
-
+        $("#login-dashboard").click(function() {
             $.ajax({
-                type: "POST",
-                url: location.pathname,
+                type: 'POST',
+                url: '/auth/login',
                 dataType: "json",
                 data: {
-                    {if $config['enable_login_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-                    recaptcha: grecaptcha.getResponse(),
-                    {/if}
-                    {if $geetest_html != null}
-                    geetest_challenge: validate.geetest_challenge,
-                    geetest_validate: validate.geetest_validate,
-                    geetest_seccode: validate.geetest_seccode,
-                    {/if}
-                    code: $$getValue('code'),
-                    email: $$getValue('email'),
-                    passwd: $$getValue('passwd'),
-                    remember_me: $("#remember_me:checked").val()
+                    code: $('#code').val(),
+                    email: $('#email').val(),
+                    passwd: $('#passwd').val(),
+                    remember_me: $('#remember_me').val()
                 },
-                success: (data) => {
+                success: function(data) {
                     if (data.ret == 1) {
-                        $("#result").modal();
-                        $$.getElementById('msg').innerHTML = data.msg;
-                        window.setTimeout("location.href='/user'", {$config['jump_delay']});
+                        $('#success-message').text(data.msg);
+                        $('#success-dialog').modal('show');
                     } else {
-                        $("#result").modal();
-                        $$.getElementById('msg').innerHTML = data.msg;
-                        document.getElementById("login").disabled = false;
-                        {if $geetest_html != null}
-                        captcha.refresh();
-                        {/if}
+                        $('#fail-message').text(data.msg);
+                        $('#fail-dialog').modal('show');
                     }
-                },
-                error: (jqXHR) => {
-                    $("#msg-error").hide(10);
-                    $("#msg-error").show(100);
-                    $$.getElementById('msg').innerHTML = `发生错误:${
-                        jqXHR.status
-                    }`;
-                    document.getElementById("login").disabled = false;
-                    {if $geetest_html != null}
-                    captcha.refresh();
-                    {/if}
                 }
-            });
-        }
-
-        $("html").keydown(function (event) {
-            if (event.keyCode == 13) {
-                login();
-            }
-        });
-        $("#login").click(function () {
-            login();
-        });
-
-        $('div.modal').on('shown.bs.modal', function () {
-            $("div.gt_slider_knob").hide();
+            })
         });
 
-        $('div.modal').on('hidden.bs.modal', function () {
-            $("div.gt_slider_knob").show();
+        $("#success-confirm").click(function() {
+            location.reload();
         });
-    })
-</script>
-
-{if $geetest_html != null}
-    <script>
-        var handlerEmbed = function (captchaObj) {
-            // 将验证码加到id为captcha的元素里
-
-            captchaObj.onSuccess(function () {
-                validate = captchaObj.getValidate();
-            });
-
-            captchaObj.appendTo("#embed-captcha");
-
-            captcha = captchaObj;
-            // 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
-        };
-
-        initGeetest({
-            gt: "{$geetest_html->gt}",
-            challenge: "{$geetest_html->challenge}",
-            product: "embed", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
-            offline: {if $geetest_html->success}0{else}1{/if} // 表示用户后台检测极验服务器是否宕机,与SDK配合,用户一般不需要关注
-        }, handlerEmbed);
     </script>
-{/if}
+</body>
 
-{if $config['enable_login_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-    <script src="https://recaptcha.net/recaptcha/api.js" async defer></script>
-{/if}
+</html>

+ 187 - 436
resources/views/material/auth/register.tpl

@@ -1,480 +1,231 @@
-{include file='header.tpl'}
-
-<div class="authpage auth-reg">
-    <div class="container">
-        <section class="content-inner">
-            <div class="auth-main auth-row">
-                <div class="auth-top auth-row">
-                    <a class="boardtop-left" href="/">
-                        <div>首 页</div>
-                    </a>
-                    <div class="auth-logo">
-                        <img src="/images/uim-logo-round.png">
-                    </div>
-                    <a href="/auth/login" class="boardtop-right">
-                        <div>登 录</div>
-                    </a>
-                </div>
-                {if $config['register_mode']!='close'}
-                    <div class="rowtocol">
-                        <div class="auth-row">
-                            <div class="form-group-label auth-row">
-                                <label class="floating-label" for="name">昵称</label>
-                                <input class="form-control maxwidth-auth" id="name" type="text">
-                            </div>
-                        </div>
-                    </div>
-                    <div class="rowtocol">
-                        <div class="auth-row">
-                            <div class="form-group-label auth-row">
-                                <label class="floating-label" for="email">邮箱(唯一凭证请认真对待)</label>
-                                <input class="form-control maxwidth-auth" id="email" type="email" maxlength="32" inputmode="email" autocomplete="username">
-                            </div>
+<!doctype html>
+<!--
+* Tabler - Premium and Open Source dashboard template with responsive and high quality UI.
+* @version 1.0.0-beta9
+* @link https://tabler.io
+* Copyright 2018-2022 The Tabler Authors
+* Copyright 2018-2022 codecalm.net Paweł Kuna
+* Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
+-->
+<html lang="zh">
+
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>{$config['appName']}</title>
+    <!-- CSS files -->
+    <link href="/theme/tabler/css/tabler.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-flags.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-payments.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/tabler-vendors.min.css" rel="stylesheet" />
+    <link href="/theme/tabler/css/demo.min.css" rel="stylesheet" />
+    <script src="/theme/tabler/js/jquery-3.6.0.min.js"></script>
+    <script src="/theme/tabler/js/tabler.min.js"></script>
+</head>
+
+<body class=" border-top-wide border-primary d-flex flex-column">
+    <div class="page page-center">
+        <div class="container-tight py-4">
+            <div class="text-center mb-4">
+                <a href="#" class="navbar-brand navbar-brand-autodark">
+                    <img src="/images/uim-logo-round.png" height="64" alt="">
+                </a>
+            </div>
+            <div class="card card-md">
+                {if $config['register_mode'] != 'close'}
+                    <div class="card-body">
+                        <h2 class="card-title text-center mb-4">注册账户</h2>
+                        <div class="mb-3">
+                            <input id="name" type="text" class="form-control" placeholder="昵称">
                         </div>
-                    </div>
-                    <div class="rowtocol">
-                        <div class="auth-row">
-                            <div class="form-group-label auth-row">
-                                <label class="floating-label" for="passwd">密码</label>
-                                <input class="form-control maxwidth-auth" id="passwd" type="password" autocomplete="new-password">
-                                <p id="passwd-strong" style="text-align: left; margin: 3px; font-size: 80%"></p>
-                            </div>
+                        <div class="mb-3">
+                            <input id="email" type="email" class="form-control" placeholder="电子邮箱">
                         </div>
-                    </div>
-                    <div class="rowtocol">
-                        <div class="auth-row">
-                            <div class="form-group form-group-label">
-                                <label class="floating-label" for="repasswd">重复密码</label>
-                                <input class="form-control maxwidth-auth" id="repasswd" type="password" autocomplete="new-password">
+                        <div class="mb-3">
+                            <div class="input-group input-group-flat">
+                                <input id="passwd" type="password" class="form-control" placeholder="登录密码">
                             </div>
                         </div>
-                    </div>
-                    {if $config['enable_reg_im'] == true}
-                        <div class="rowtocol">
-                            <div class="auth-row">
-                                <div class="form-group form-group-label dropdown">
-                                    <label class="floating-label" for="im_type">选择您的联络方式</label>
-                                    <button class="form-control maxwidth-auth" id="im_type" data-toggle="dropdown">
-
-                                    </button>
-                                    <ul class="dropdown-menu" aria-labelledby="im_type">
-                                        <li><a href="#" class="dropdown-option" onclick="return false;" val="1"
-                                           data="im_type">微信</a></li>
-                                        <li><a href="#" class="dropdown-option" onclick="return false;" val="2"
-                                           data="im_type">QQ</a></li>
-                                        <li><a href="#" class="dropdown-option" onclick="return false;" val="4"
-                                           data="im_type">Telegram</a></li>
-                                        <li><a href="#" class="dropdown-option" onclick="return false;" val="5"
-                                               data="im_type">Discord</a></li>
-                                    </ul>
-                                </div>
+                        <div class="mb-3">
+                            <div class="input-group input-group-flat">
+                                <input id="repasswd" type="password" class="form-control" placeholder="重复登录密码">
                             </div>
                         </div>
-                        <div class="rowtocol">
-                            <div class="auth-row">
-                                <div class="form-group form-group-label">
-                                    <label class="floating-label" for="im_value">在这输入联络方式账号</label>
-                                    <input class="form-control maxwidth-auth" id="im_value" type="text">
-                                </div>
+                        {if $config['enable_reg_im'] == true}
+                            <div class="mb-3">
+                                <select id="im_type" class="col form-select">
+                                    <option value="0">请选择社交软件</option>
+                                    <option value="1">微信</option>
+                                    <option value="2">QQ</option>
+                                    <option value="4">Telegram</option>
+                                    <option value="5">Discord</option>
+                                </select>
                             </div>
-                        </div>
-                    {/if}
-                    {if $config['register_mode'] == 'invite'}
-                        <div class="rowtocol">
-                            <div class="auth-row">
-                                <div class="form-group form-group-label">
-                                    <label class="floating-label" for="code">邀请码(必填)</label>
-                                    <input class="form-control maxwidth-auth" id="code" type="text">
+                            <div class="mb-3">
+                                <div class="input-group input-group-flat">
+                                    <input id="im_value" type="text" class="form-control" placeholder="社交账号">
                                 </div>
                             </div>
-                        </div>
-                    {/if}
-                    {if $enable_email_verify == true}
-                        <div class="rowtocol">
-                            <div class="rowtocol">
-                                <div class="form-group form-group-label">
-                                    <label class="floating-label" for="email_code">邮箱验证码</label>
-                                    <input class="form-control maxwidth-auth" id="email_code" type="text"
-                                           onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" autocomplete="one-time-code">
+                        {/if}
+                        {if $config['register_mode'] != 'close' }
+                            <div class="mb-3">
+                                <div class="input-group input-group-flat">
+                                    <input id="code" type="text" class="form-control" placeholder="注册邀请码" value="{$code}">
                                 </div>
                             </div>
-                            <div class="rowtocol">
-                                <div class="form-group form-group-label">
-                                    <button id="email_verify"
-                                            class="btn-reg btn btn-block btn-brand-accent waves-attach waves-light">
-                                        获取验证码
-                                    </button>
-                                    <a href="" onclick="return false;" data-toggle='modal'
-                                       data-target='#email_nrcy_modal'
-                                       class="auth-help-reg">收不到验证码?</a>
+                        {/if}
+                        {if $enable_email_verify == true}
+                            <div class="mb-3">
+                                <div class="input-group mb-2">
+                                    <input id="emailcode" type="text" class="form-control" placeholder="邮箱验证码">
+                                    <button id="email-verify" class="btn text-blue" type="button">获取</button>
                                 </div>
                             </div>
+                        {/if}
+                        <div class="mb-3">
+                            <label class="form-check">
+                                <input id="tos" type="checkbox" class="form-check-input" />
+                                <span class="form-check-label">
+                                    我已阅读并同意 <a href="/tos" tabindex="-1"> 服务条款与隐私政策 </a>
+                                </span>
+                            </label>
                         </div>
-                    {/if}
-
-                    {if $geetest_html != null}
-                        <div class="rowtocol">
-                            <div class="form-group form-group-label">
-                                <div id="embed-captcha"></div>
-                            </div>
-                        </div>
-                    {/if}
-                    {if $config['enable_reg_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-                        <div class="form-group form-group-label">
-                            <div class="row">
-                                <div align="center" class="g-recaptcha" data-sitekey="{$recaptcha_sitekey}"></div>
-                            </div>
-                        </div>
-                    {/if}
-                    <div class="rowtocol">
-                        <div class="btn-auth auth-row">
-                            <button id="tos" type="submit"
-                                    class="btn-reg btn btn-block btn-brand waves-attach waves-light">确认注册
-                            </button>
+                        <div class="form-footer">
+                            <button id="confirm-register" type="submit" class="btn btn-primary w-100">注册新账户</button>
                         </div>
                     </div>
                 {else}
-                    <div class="form-group">
-                        <p>{$config['appName']} 已停止新用户注册,请联系网站管理员</p>
+                    <div class="card-body">
+                        <p>还没有开放注册,过两天再来看看吧</p>
                     </div>
                 {/if}
-                <div class="auth-bottom auth-row auth-reg">
-                    <div class="tgauth">
-
-                        <p>注册即代表同意<a href="/tos">服务条款</a>,以及保证所录入信息的真实性,如有不实信息会导致账号被删除。</p>
-
-                    </div>
-                </div>
-            </div>
-        </section>
-    </div>
-</div>
-
-<div aria-hidden="true" class="modal modal-va-middle fade" id="tos_modal" role="dialog" tabindex="-1">
-    <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-heading">
-                <h2 class="modal-title">注册 TOS</h2>
             </div>
-            <div class="modal-inner">
-                {include file='reg_tos.tpl'}
-            </div>
-            <div class="modal-footer">
-                <p class="text-right">
-                    <button class="btn btn-flat btn-brand-accent waves-attach waves-effect"
-                            data-dismiss="modal" type="button" id="cancel">我不同意
-                    </button>
-                    <button class="btn btn-flat btn-brand-accent waves-attach waves-effect" data-dismiss="modal"
-                            id="reg"
-                            type="button">我同意
-                    </button>
-                </p>
+            <div class="text-center text-muted mt-3">
+                已有账户? <a href="/auth/login" tabindex="-1">点击登录</a>
             </div>
         </div>
     </div>
-</div>
 
-<div aria-hidden="true" class="modal modal-va-middle fade" id="email_nrcy_modal" role="dialog" tabindex="-1">
-    <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-heading">
-                <h2 class="modal-title">收不到验证码?</h2>
-            </div>
-            <div class="modal-inner">
-                {include file='email_nrcy.tpl'}
+    <div class="modal modal-blur fade" id="success-dialog" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
+            <div class="modal-content">
+                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+                <div class="modal-status bg-success"></div>
+                <div class="modal-body text-center py-4">
+                    <svg xmlns="http://www.w3.org/2000/svg" class="icon mb-2 text-green icon-lg" width="24" height="24"
+                        viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
+                        stroke-linejoin="round">
+                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                        <circle cx="12" cy="12" r="9" />
+                        <path d="M9 12l2 2l4 -4" />
+                    </svg>
+                    <p id="success-message" class="text-muted">成功</p>
+                </div>
+                <div class="modal-footer">
+                    <div class="w-100">
+                        <div class="row">
+                            <div class="col">
+                                <a id="success-confirm" href="#" class="btn w-100" data-bs-dismiss="modal">
+                                    好
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </div>
             </div>
-            <div class="modal-footer">
-                <p class="text-right">
-                    <button class="btn btn-flat btn-brand-accent waves-attach waves-effect" data-dismiss="modal"
-                            type="button">我知道了
-                    </button>
-                </p>
+        </div>
+    </div>
+    <div class="modal modal-blur fade" id="fail-dialog" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
+            <div class="modal-content">
+                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+                <div class="modal-status bg-danger"></div>
+                <div class="modal-body text-center py-4">
+                    <svg xmlns="http://www.w3.org/2000/svg" class="icon mb-2 text-danger icon-lg" width="24" height="24"
+                        viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
+                        stroke-linejoin="round">
+                        <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+                        <path d="M12 9v2m0 4v.01" />
+                        <path
+                            d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75" />
+                    </svg>
+                    <p id="fail-message" class="text-muted">失败</p>
+                </div>
+                <div class="modal-footer">
+                    <div class="w-100">
+                        <div class="row">
+                            <div class="col">
+                                <a href="#" class="btn btn-danger w-100" data-bs-dismiss="modal">
+                                    确认
+                                </a>
+                            </div>
+                        </div>
+                    </div>
+                </div>
             </div>
         </div>
     </div>
-</div>
-
-<div class="tiphidden"></div>
-
-{include file='dialog.tpl'}
-
-{include file='footer.tpl'}
-
-<script>
-const checkStrong = (sValue) => {
-    let modes = 0;
-    if (sValue.length < 7) return modes;
-    if (/\d/.test(sValue)) modes++;
-    if (/[a-z]/.test(sValue)) modes++;
-    if (/[A-Z]/.test(sValue)) modes++;
-    if (/\W/.test(sValue)) modes++;
-
-    switch (modes) {
-        case 1:
-            return 1;
-            break;
-        case 2:
-            return 2;
-        case 3:
-        case 4:
-            return sValue.length < 12 ? 3 : 4
-            break;
-    }
-}
-
-const showStrong = () => {
-    const password = document.getElementById('passwd').value;
-    const $passwordStrongEl = document.getElementById('passwd-strong');
-    const strong = checkStrong(password);
-    if (strong = 0) {
-        $passwordStrongEl.innerHTML = '需大于 8 位;推荐使用包含大小写字母、数字、符号的密码';
-    } else if (strong = 1) {
-        $passwordStrongEl.innerHTML = '你的密码强度为: <span style="color: red; font-weight: bold">非常弱</span>';
-    } else if (strong = 2) {
-        $passwordStrongEl.innerHTML = '你的密码强度为: <span style="color: red; font-weight: bold">弱</span>';
-    } else if (strong = 3) {
-        $passwordStrongEl.innerHTML = '你的密码强度为: <span style="color: yellow; font-weight: bold">中等</span>';
-    } else if (strong = 4) {
-        $passwordStrongEl.innerHTML = '你的密码强度为: <span style="color: green; font-weight: bold">强</span>';
-    }
-}
-
-document.getElementById('passwd').addEventListener('input', checkStrong);
-</script>
 
-{if $config['register_mode']!='close'}
     <script>
-        $(document).ready(function () {
-            function register() {
-                {if $config['register_mode'] == 'invite'}
-                code = $$getValue('code');
-                {else}
-                code = 0;
-                if ((getCookie('code')) != '') {
-                    code = getCookie('code');
-                }
-                {/if}
-                document.getElementById("tos").disabled = true;
-
+        {if $enable_email_verify == true}
+            $("#email-verify").click(function() {
                 $.ajax({
-                    type: "POST",
-                    url: location.pathname,
+                    type: 'POST',
+                    url: '/auth/send',
                     dataType: "json",
                     data: {
-                        {if $config['enable_reg_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-                        recaptcha: grecaptcha.getResponse(),
-                        {/if}
-                        {if $geetest_html != null}
-                        geetest_challenge: validate.geetest_challenge,
-                        geetest_validate: validate.geetest_validate,
-                        geetest_seccode: validate.geetest_seccode,
-                        {/if}
-                        {if $config['enable_reg_im'] == true}
-                        im_value: $$getValue('im_value'),
-                        im_type: $$getValue('im_type'),
-                        {/if}
-                        {if $enable_email_verify == true}
-                        emailcode: $$getValue('email_code'),
-                        {/if}
-                        code,
-                        name: $$getValue('name'),
-                        email: $$getValue('email'),
-                        passwd: $$getValue('passwd'),
-                        repasswd: $$getValue('repasswd')
+                        email: $('#email').val(),
                     },
-                    success: (data) => {
+                    success: function(data) {
                         if (data.ret == 1) {
-                            $("#result").modal();
-                            $$.getElementById('msg').innerHTML = data.msg;
-                            window.setTimeout("location.href='/user'", {$config['jump_delay']});
+                            $('#success-message').text(data.msg);
+                            $('#success-dialog').modal('show');
                         } else {
-                            $("#result").modal();
-                            $$.getElementById('msg').innerHTML = data.msg;
-                            setCookie('code', '', 0);
-                            $("#code").val(getCookie('code'));
-                            document.getElementById("tos").disabled = false;
-                            {if $geetest_html != null}
-                            captcha.refresh();
-                            {/if}
+                            $('#fail-message').text(data.msg);
+                            $('#fail-dialog').modal('show');
                         }
-                    },
-                    error: (jqXHR) => {
-                        $("#msg-error").hide(10);
-                        $("#msg-error").show(100);
-                        $$.getElementById('msg-error-p').innerHTML = `发生错误:${
-                                jqXHR.status
-                                }`;
-                        document.getElementById("tos").disabled = false;
-                        {if $geetest_html != null}
-                        captcha.refresh();
-                        {/if}
                     }
-                });
-            }
-
-            $("html").keydown(function (event) {
-                if (event.keyCode == 13) {
-                    $("#tos_modal").modal();
-                }
-            });
-
-            {if $geetest_html != null}
-            $('div.modal').on('shown.bs.modal', function () {
-                $("div.gt_slider_knob").hide();
-            });
-
-
-            $('div.modal').on('hidden.bs.modal', function () {
-                $("div.gt_slider_knob").show();
-            });
-
-
-            {/if}
-
-            $("#reg").click(function () {
-                register();
-            });
-
-            $("#tos").click(function () {
-                {if $geetest_html != null}
-                if (typeof validate === 'undefined' || !validate) {
-                    $("#result").modal();
-                    $$.getElementById('msg').innerHTML = '请滑动验证码来完成验证'
-                    return;
-                }
-
-                {/if}
-                $("#tos_modal").modal();
+                })
             });
-        })
-    </script>
-{/if}
-
-{if $enable_email_verify == true}
-    <script>
-        var wait = 60;
-
-        function time(o) {
-            if (wait == 0) {
-                o.removeAttr("disabled");
-                o.text("获取验证码");
-                wait = 60;
-            } else {
-                o.attr("disabled", "disabled");
-                o.text("重新发送(" + wait + ")");
-                wait--;
-                setTimeout(function () {
-                            time(o)
-                        },
-                        1000)
-            }
-        }
-
-        $(document).ready(function () {
-            $("#email_verify").click(function () {
-                time($("#email_verify"));
-
-                $.ajax({
-                    type: "POST",
-                    url: "send",
-                    dataType: "json",
-                    data: {
-                        email: $$getValue('email')
-                    },
-                    success: (data) => {
-                        if (data.ret) {
-                            $("#result").modal();
-                            $$.getElementById('msg').innerHTML = data.msg;
-
-                        } else {
-                            $("#result").modal();
-                            $$.getElementById('msg').innerHTML = data.msg;
-                        }
-                    },
-                    error: (jqXHR) => {
-                        $("#result").modal();
-                        $$.getElementById('msg').innerHTML = `${
-                                data.msg
-                                } 出现了一些错误`;
+        {/if}
+
+        $("#confirm-register").click(function() {
+            $.ajax({
+                type: 'POST',
+                url: '/auth/register',
+                dataType: "json",
+                data: {
+                    {if $config['enable_reg_im'] == true}
+                        im_value: $('#im_value').val(),
+                        im_type: $('#im_type').val(),
+                    {/if}
+                    {if $enable_email_verify == true}
+                        emailcode: $('#emailcode').val(),
+                    {/if}
+                    tos: $('#tos').val(),
+                    code: $('#code').val(),
+                    name: $('#name').val(),
+                    email: $('#email').val(),
+                    passwd: $('#passwd').val(),
+                    repasswd: $('#repasswd').val(),
+                },
+                success: function(data) {
+                    if (data.ret == 1) {
+                        $('#success-message').text(data.msg);
+                        $('#success-dialog').modal('show');
+                    } else {
+                        $('#fail-message').text(data.msg);
+                        $('#fail-dialog').modal('show');
                     }
-                })
+                }
             })
-        })
-    </script>
-{/if}
-
-{if $geetest_html != null}
-    <script>
-        var handlerEmbed = function (captchaObj) {
-            // 将验证码加到id为captcha的元素里
-
-            captchaObj.onSuccess(function () {
-                validate = captchaObj.getValidate();
-            });
+        });
 
-            captchaObj.appendTo("#embed-captcha");
-
-            captcha = captchaObj;
-            // 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
-        };
-
-        initGeetest({
-            gt: "{$geetest_html->gt}",
-            challenge: "{$geetest_html->challenge}",
-            product: "embed", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
-            offline: {if $geetest_html->success}0{else}1{/if} // 表示用户后台检测极验服务器是否宕机,与SDK配合,用户一般不需要关注
-        }, handlerEmbed);
+        $("#success-confirm").click(function() {
+            location.reload();
+        });
     </script>
-{/if}
-
-{if $config['enable_reg_captcha'] == true && $config['captcha_provider'] == 'recaptcha'}
-    <script src="https://recaptcha.net/recaptcha/api.js" async defer></script>
-{/if}
-
-{*dumplin:aff链*}
-<script>
-    {*dumplin:轮子1.js读取url参数*}
-    function getQueryVariable(variable) {
-        var query = window.location.search.substring(1);
-        var vars = query.split("&");
-        for (var i = 0; i < vars.length; i++) {
-            var pair = vars[i].split("=");
-            if (pair[0] == variable) {
-                return pair[1];
-            }
-        }
-        return "";
-    }
-
-    {*dumplin:轮子2.js写入cookie*}
-    function setCookie(cname, cvalue, exdays) {
-        var d = new Date();
-        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
-        var expires = "expires=" + d.toGMTString();
-        document.cookie = cname + "=" + cvalue + "; " + expires;
-    }
-
-    {*dumplin:轮子3.js读取cookie*}
-    function getCookie(cname) {
-        var name = cname + "=";
-        var ca = document.cookie.split(';');
-        for (var i = 0; i < ca.length; i++) {
-            var c = ca[i].trim();
-            if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
-        }
-        return "";
-    }
-
-    {*dumplin:读取url参数写入cookie,自动跳转隐藏url邀请码*}
-    if (getQueryVariable('code') != '') {
-        setCookie('code', getQueryVariable('code'), 30);
-        window.location.href = '/auth/register';
-    }
+</body>
 
-    {if $config['register_mode'] == 'invite'}
-    {*dumplin:读取cookie,自动填入邀请码框*}
-    if ((getCookie('code')) != '') {
-        $("#code").val(getCookie('code'));
-    }
-    {/if}
-</script>
+</html>

+ 16 - 14
resources/views/material/user/index.tpl

@@ -16,8 +16,7 @@
                 {if $config['enable_ticket'] == true}
                     <div class="col-auto ms-auto d-print-none">
                         <div class="btn-list">
-                            <a href="/user/ticket/create" class="btn btn-primary d-none d-sm-inline-block"
-                                data-bs-toggle="modal">
+                            <a href="/user/ticket/create" class="btn btn-primary d-none d-sm-inline-block">
                                 <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
                                     viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                                     stroke-linecap="round" stroke-linejoin="round">
@@ -27,7 +26,7 @@
                                 </svg>
                                 提交工单
                             </a>
-                            <a href="/user/ticket/create" class="btn btn-primary d-sm-none btn-icon" data-bs-toggle="modal">
+                            <a href="/user/ticket/create" class="btn btn-primary d-sm-none btn-icon">
                                 <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
                                     viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                                     stroke-linecap="round" stroke-linejoin="round">
@@ -213,16 +212,15 @@
                                         <div class="col-auto">
                                             <span class="bg-facebook text-white avatar">
                                                 <svg xmlns="http://www.w3.org/2000/svg"
-                                                    class="icon icon-tabler icon-tabler-speedboat" width="24"
-                                                    height="24" viewBox="0 0 24 24" stroke-width="2"
-                                                    stroke="currentColor" fill="none" stroke-linecap="round"
-                                                    stroke-linejoin="round">
+                                                    class="icon icon-tabler icon-tabler-rocket" width="24" height="24"
+                                                    viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
+                                                    fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                     <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                     <path
-                                                        d="M3 17h13.4a3 3 0 0 0 2.5 -1.34l3.1 -4.66h0h-6.23a4 4 0 0 0 -1.49 .29l-3.56 1.42a4 4 0 0 1 -1.49 .29h-3.73h0h-1l-1.5 4z">
+                                                        d="M4 13a8 8 0 0 1 7 7a6 6 0 0 0 3 -5a9 9 0 0 0 6 -8a3 3 0 0 0 -3 -3a9 9 0 0 0 -8 6a6 6 0 0 0 -5 3">
                                                     </path>
-                                                    <line x1="6" y1="13" x2="7.5" y2="8"></line>
-                                                    <path d="M6 8h8l2 3"></path>
+                                                    <path d="M7 14a6 6 0 0 0 -3 6a6 6 0 0 0 6 -3"></path>
+                                                    <circle cx="15" cy="9" r="1"></circle>
                                                 </svg>
                                             </span>
                                         </div>
@@ -260,7 +258,7 @@
                             </svg>
                         </div>
                         <div class="card-body">
-                            <h3 class="card-title">最新公告</h3>
+                            <h3 class="card-title">最新公告 <span class="card-subtitle">{$ann->date}</span></h3>
                             <hr />
                             <p class="text-muted">
                                 {$ann->content}
@@ -275,9 +273,13 @@
                                 <div class="card-body">
                                     <h3 class="card-title">流量用量</h3>
                                     <div class="progress progress-separated mb-3">
-                                        <div class="progress-bar bg-primary" role="progressbar"
-                                            style="width: {$user->LastusedTrafficPercent()}%">
-                                        </div>
+                                        {if $user->LastusedTrafficPercent() < '1'}
+                                            <div class="progress-bar bg-primary" role="progressbar" style="width: 1%"></div>
+                                        {else}
+                                            <div class="progress-bar bg-primary" role="progressbar"
+                                                style="width: {$user->LastusedTrafficPercent()}%">
+                                            </div>
+                                        {/if}
                                         {if $user->TodayusedTrafficPercent() < '1'}
                                             <div class="progress-bar bg-success" role="progressbar" style="width: 1%"></div>
                                         {else}

+ 207 - 554
src/Controllers/AuthController.php

@@ -1,634 +1,287 @@
 <?php
-
 namespace App\Controllers;
 
-use App\Models\{
-    User,
-    Setting,
-    InviteCode,
-    EmailVerify
-};
-use App\Utils\{
-    GA,
-    Hash,
-    Check,
-    Tools,
-    TelegramSessionManager
-};
-use App\Services\{
-    Auth,
-    Captcha,
-    Mail,
-    Config
-};
-use voku\helper\AntiXSS;
-use Exception;
+use App\Utils\GA;
+use App\Utils\Hash;
+use App\Utils\Tools;
 use Ramsey\Uuid\Uuid;
-use Slim\Http\{
-    Request,
-    Response
-};
+use App\Services\Auth;
+use App\Services\Mail;
+use Slim\Http\Response;
+use voku\helper\AntiXSS;
+use App\Models\User;
+use App\Models\Setting;
+use App\Models\InviteCode;
+use App\Models\EmailVerify;
 
-/**
- *  AuthController
- */
 class AuthController extends BaseController
 {
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
     public function login($request, $response, $args)
     {
-        $captcha = Captcha::generate();
-
-        if ($_ENV['enable_telegram_login'] === true) {
-            $login_text   = TelegramSessionManager::add_login_session();
-            $login        = explode('|', $login_text);
-            $login_token  = $login[0];
-            $login_number = $login[1];
-        } else {
-            $login_token  = '';
-            $login_number = '';
-        }
-
-        if (Setting::obtain('enable_login_captcha') == true) {
-            $geetest_html = $captcha['geetest'];
-        } else {
-            $geetest_html = null;
-        }
-
-        return $this->view()
-            ->assign('geetest_html', $geetest_html)
-            ->assign('login_token', $login_token)
-            ->assign('login_number', $login_number)
-            ->assign('telegram_bot', $_ENV['telegram_bot'])
-            ->assign('base_url', $_ENV['baseUrl'])
-            ->assign('recaptcha_sitekey', $captcha['recaptcha'])
-            ->display('auth/login.tpl');
+        return $this->view()->display('auth/login.tpl');
     }
 
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function getCaptcha($request, $response, $args)
-    {
-        $captcha = Captcha::generate();
-        return $response->withJson([
-            'recaptchaKey' => $captcha['recaptcha'],
-            'GtSdk'        => $captcha['geetest'],
-            'respon'       => 1,
-        ]);
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
     public function loginHandle($request, $response, $args)
     {
-        $email      = trim($request->getParam('email'));
-        $email      = strtolower($email);
-        $passwd     = $request->getParam('passwd');
-        $code       = $request->getParam('code');
+        $code = $request->getParam('code');
+        $email = strtolower(trim($request->getParam('email')));
+        $passwd = $request->getParam('passwd');
         $rememberMe = $request->getParam('remember_me');
-
-        if (Setting::obtain('enable_login_captcha') == true) {
-            $ret = Captcha::verify($request->getParams());
-            if (!$ret) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '系统无法接受您的验证结果,请刷新页面后重试。'
-                ]);
-            }
-        }
-
         $user = User::where('email', $email)->first();
-        if ($user == null) {
-            return $response->withJson([
-                'ret' => 0,
-                'msg' => '邮箱不存在'
-            ]);
-        }
-
-        if (!Hash::checkPassword($user->pass, $passwd)) {
-            // 记录登录失败
-            $user->collectLoginIP($_SERVER['REMOTE_ADDR'], 1);
-            return $response->withJson([
-                'ret' => 0,
-                'msg' => '邮箱或者密码错误'
-            ]);
-        }
 
-        if ($user->ga_enable == 1) {
-            $ga    = new GA();
-            $rcode = $ga->verifyCode($user->ga_token, $code);
-            if (!$rcode) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '两步验证码错误,如果您是丢失了生成器或者错误地设置了这个选项,您可以尝试重置密码,即可取消这个选项。'
-                ]);
+        try {
+            if ($user == null) {
+                throw new \Exception('没有找到这个邮箱');
+            }
+            if (!Hash::checkPassword($user->pass, $passwd)) {
+                $user->collectLoginIP($_SERVER['REMOTE_ADDR'], 1);
+                throw new \Exception('登录密码不正确');
+            }
+            if ($user->ga_enable == 1) {
+                $ga = new GA();
+                $rcode = $ga->verifyCode($user->ga_token, $code);
+                if (!$rcode) {
+                    throw new \Exception('两步验证码错误,如丢失密钥,请重置密码');
+                }
             }
-        }
-
-        $time = 3600 * 24;
-        if ($rememberMe) {
-            $time = 3600 * 24 * ($_ENV['cookie_expiration_time'] ?: 7);
-        }
-
-        Auth::login($user->id, $time);
-        // 记录登录成功
-        $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
-
-        return $response->withJson([
-            'ret' => 1,
-            'msg' => '登录成功'
-        ]);
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function qrcode_loginHandle($request, $response, $args)
-    {
-        $token  = $request->getParam('token');
-        $number = $request->getParam('number');
 
-        $ret = TelegramSessionManager::step2_verify_login_session($token, $number);
-        if ($ret === 0) {
+            $time = 3600 * 24;
+            Auth::login($user->id, $time);
+            $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
+        } catch (\Exception $e) {
             return $response->withJson([
                 'ret' => 0,
-                'msg' => '此令牌无法被使用。'
+                'msg' => $e->getMessage()
             ]);
         }
 
-        $user = User::find($ret);
-
-        Auth::login($user->id, 3600 * 24);
-        // 记录登录成功
-        $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
-
         return $response->withJson([
             'ret' => 1,
-            'msg' => '登录成功'
+            'msg' => '登录成功,欢迎回来'
         ]);
     }
 
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function register($request, $response, $next)
-    {
-        $ary  = $request->getQueryParams();
-        $code = '';
-        if (isset($ary['code'])) {
-            $antiXss = new AntiXSS();
-            $code    = $antiXss->xss_clean($ary['code']);
-        }
-
-        $captcha = Captcha::generate();
-
-        if ($_ENV['enable_telegram_login'] === true) {
-            $login_text   = TelegramSessionManager::add_login_session();
-            $login        = explode('|', $login_text);
-            $login_token  = $login[0];
-            $login_number = $login[1];
-        } else {
-            $login_token  = '';
-            $login_number = '';
-        }
-
-        if (Setting::obtain('enable_reg_captcha') == true) {
-            $geetest_html = $captcha['geetest'];
-        } else {
-            $geetest_html = null;
-        }
-
-        return $this->view()
-            ->assign('geetest_html', $geetest_html)
-            ->assign('enable_email_verify', Setting::obtain('reg_email_verify'))
-            ->assign('code', $code)
-            ->assign('recaptcha_sitekey', $captcha['recaptcha'])
-            ->assign('telegram_bot', $_ENV['telegram_bot'])
-            ->assign('base_url', $_ENV['baseUrl'])
-            ->assign('login_token', $login_token)
-            ->assign('login_number', $login_number)
-            ->display('auth/register.tpl');
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
     public function sendVerify($request, $response, $next)
     {
-        if (Setting::obtain('reg_email_verify')) {
-            $email = trim($request->getParam('email'));
-            $email = strtolower($email);
+        try {
+            if (!Setting::obtain('reg_email_verify')) {
+                throw new \Exception('不需要验证邮箱');
+            }
+            if (Setting::obtain('mail_driver') == 'none') {
+                throw new \Exception('没有有效的发信配置');
+            }
+            $email = strtolower(trim($request->getParam('email')));
             if ($email == '') {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '未填写邮箱'
-                ]);
+                throw new \Exception('请填写邮箱');
             }
-            // check email format
-            $check_res = Check::isEmailLegal($email);
-            if ($check_res['ret'] == 0) {
-                return $response->withJson($check_res);
+            if (!Tools::emailCheck($email)) {
+                throw new \Exception('邮箱格式不正确');
             }
             $user = User::where('email', $email)->first();
             if ($user != null) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '此邮箱已经注册'
-                ]);
+                throw new \Exception('此邮箱已注册');
             }
-            $ipcount = EmailVerify::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('expire_in', '>', time())->count();
+            $ipcount = EmailVerify::where('ip', $_SERVER['REMOTE_ADDR'])
+            ->where('expire_in', '>', time())
+            ->count();
             if ($ipcount >= Setting::obtain('email_verify_ip_limit')) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '此IP请求次数过多'
-                ]);
+                throw new \Exception('此IP请求次数过多');
             }
-            $mailcount = EmailVerify::where('email', '=', $email)->where('expire_in', '>', time())->count();
+            $mailcount = EmailVerify::where('email', $email)
+            ->where('expire_in', '>', time())
+            ->count();
             if ($mailcount >= 3) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '此邮箱请求次数过多'
-                ]);
+                throw new \Exception('此邮箱请求次数过多');
             }
-            $code          = Tools::genRandomNum(6);
-            $ev            = new EmailVerify();
+
+            $code = Tools::genRandomNum(6);
+            $ev = new EmailVerify();
             $ev->expire_in = time() + Setting::obtain('email_verify_ttl');
-            $ev->ip        = $_SERVER['REMOTE_ADDR'];
-            $ev->email     = $email;
-            $ev->code      = $code;
+            $ev->ip = $_SERVER['REMOTE_ADDR'];
+            $ev->email = $email;
+            $ev->code = $code;
             $ev->save();
-            try {
-                Mail::send(
-                    $email,
-                    $_ENV['appName'] . '- 验证邮件',
-                    'auth/verify.tpl',
-                    [
-                        'code' => $code,
-                        'expire' => date('Y-m-d H:i:s', time() + Setting::obtain('email_verify_ttl'))
-                    ],
-                    []
-                );
-            } catch (Exception $e) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '验证码发送失败'
-                ]);
-            }
+
+            Mail::send($email, $_ENV['appName'] . ' - 验证邮件', 'auth/verify.tpl',
+                [
+                    'code' => $code,
+                    'expire' => date('Y-m-d H:i:s', time() + Setting::obtain('email_verify_ttl'))
+                ], []
+            );
+        } catch (\Exception $e) {
             return $response->withJson([
-                'ret' => 1,
-                'msg' => '验证码发送成功,请查收'
+                'ret' => 0,
+                'msg' => $e->getMessage()
             ]);
         }
 
         return $response->withJson([
-            'ret' => 0,
-            'msg' => '没有启用邮箱验证'
+            'ret' => 1,
+            'msg' => '请查收验证码'
         ]);
     }
 
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function register_helper($name, $email, $passwd, $code, $imtype, $imvalue, $telegram_id)
+    public function register($request, $response, $next)
     {
-        if (Setting::obtain('reg_mode') == 'close') {
-            $res['ret'] = 0;
-            $res['msg'] = '暂时不对外开放注册';
-            return $res;
-        }
+        $anti_xss = new AntiXSS();
+        $code = $anti_xss->xss_clean(trim($request->getParam('code')));
 
-        if ($code == '') {
-            $res['ret'] = 0;
-            $res['msg'] = '注册需要填写邀请码';
-            return $res;
-        }
+        return $this->view()
+            ->assign('code', $code)
+            ->assign('enable_email_verify', Setting::obtain('reg_email_verify'))
+            ->display('auth/register.tpl');
+    }
 
-        $c = InviteCode::where('code', $code)->first();
-        if ($c == null) {
-            if (Setting::obtain('reg_mode') == 'invite') {
-                $res['ret'] = 0;
-                $res['msg'] = '这个邀请码不存在';
-                return $res;
+    public function registerHandle($request, $response, $args)
+    {
+        try {
+            $tos = $request->getParam('tos');
+            $name = trim($request->getParam('name'));
+            $passwd = $request->getParam('passwd');
+            $repasswd = $request->getParam('repasswd');
+            $code = trim($request->getParam('code'));
+            $emailcode = trim($request->getParam('emailcode'));
+            $email = strtolower(trim($request->getParam('email')));
+            $reg_mode = Setting::obtain('reg_mode');
+
+            if ($name == '') {
+                throw new \Exception('请填写昵称');
             }
-        } elseif ($c->user_id != 0) {
-            $gift_user = User::where('id', $c->user_id)->first();
-            if ($gift_user == null) {
-                $res['ret'] = 0;
-                $res['msg'] = '邀请码已失效';
-                return $res;
+            if ($email == '') {
+                throw new \Exception('请填写注册邮箱');
             }
-
-            if ($gift_user->invite_num == 0) {
-                $res['ret'] = 0;
-                $res['msg'] = '邀请码不可用';
-                return $res;
+            if (!Tools::emailCheck($email)) {
+                throw new \Exception('邮箱格式不正确');
             }
-        }
-
-        $configs = Setting::getClass('register');
-        // do reg user
-        $user                       = new User();
-        $antiXss                    = new AntiXSS();
-        $current_timestamp          = time();
-
-        $user->user_name            = $antiXss->xss_clean($name);
-        $user->email                = $email;
-        $user->pass                 = Hash::passwordHash($passwd);
-        $user->passwd               = Tools::genRandomChar(16);
-        $user->uuid                 = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . $current_timestamp);
-        $user->port                 = Tools::getAvPort();
-        $user->t                    = 0;
-        $user->u                    = 0;
-        $user->d                    = 0;
-        $user->method               = $configs['sign_up_for_method'];
-        $user->protocol             = $configs['sign_up_for_protocol'];
-        $user->protocol_param       = $configs['sign_up_for_protocol_param'];
-        $user->obfs                 = $configs['sign_up_for_obfs'];
-        $user->obfs_param           = $configs['sign_up_for_obfs_param'];
-        $user->forbidden_ip         = $_ENV['reg_forbidden_ip'];
-        $user->forbidden_port       = $_ENV['reg_forbidden_port'];
-        $user->im_type              = $imtype;
-        $user->im_value             = $antiXss->xss_clean($imvalue);
-
-        $user->transfer_enable      = Tools::toGB($configs['sign_up_for_free_traffic']);
-        $user->invite_num           = $configs['sign_up_for_invitation_codes'];
-        $user->auto_reset_day       = '0';
-        $user->auto_reset_bandwidth = '0';
-        $user->money                = 0;
-        $user->sendDailyMail        = $configs['sign_up_for_daily_report'];
-
-        //dumplin:填写邀请人,写入邀请奖励
-        $user->ref_by = 0;
-        if ($c != null && $c->user_id != 0) {
-            $invitation = Setting::getClass('invite');
-            // 设置新用户
-            $user->ref_by = $c->user_id;
-            // 给邀请人反流量
-            if (($gift_user->invite_num - 1) >= 0) {
-                --$gift_user->invite_num;
-                // 避免设置为不限制邀请次数的值 -1 发生变动
+            if (strlen($passwd) < 8) {
+                throw new \Exception('密码长度需要大于 8');
             }
-            $gift_user->save();
-        }
-
-        if ($telegram_id) {
-            $user->telegram_id = $telegram_id;
-        }
-
-        $ga                     = new GA();
-        $secret                 = $ga->createSecret();
-        $user->ga_token         = $secret;
-        $user->ga_enable        = 0;
-        $user->class_expire     = date('Y-m-d H:i:s', time() + $configs['sign_up_for_class_time'] * 86400);
-        $user->class            = $configs['sign_up_for_class'];
-        $user->node_connector   = $configs['connection_device_limit'];
-        $user->node_speedlimit  = $configs['connection_rate_limit'];
-        $user->expire_in        = date('Y-m-d H:i:s', time() + $configs['sign_up_for_free_time'] * 86400);
-        $user->reg_date         = date('Y-m-d H:i:s');
-        $user->reg_ip           = $_SERVER['REMOTE_ADDR'];
-        $user->theme            = $_ENV['theme'];
-        $groups                 = explode(',', $_ENV['random_group']);
-        $user->node_group       = $groups[array_rand($groups)];
-
-        if ($user->save()) {
-            Auth::login($user->id, 3600);
-            $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
-
-            $res['ret'] = 1;
-            $res['msg'] = '注册成功!正在进入登录界面';
-            return $res;
-        }
-
-        $res['ret'] = 0;
-        $res['msg'] = '未知错误';
-        return $res;
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function registerHandle($request, $response, $args)
-    {
-        if (Setting::obtain('reg_mode') == 'close') {
-            return $response->withJson([
-                'ret' => 0,
-                'msg' => '未开放注册。'
-            ]);
-        }
-
-        $name      = $request->getParam('name');
-        $email     = $request->getParam('email');
-        $email     = trim($email);
-        $email     = strtolower($email);
-        $passwd    = $request->getParam('passwd');
-        $repasswd  = $request->getParam('repasswd');
-        $code      = trim($request->getParam('code'));
-        $emailcode = $request->getParam('emailcode');
-        $emailcode = trim($emailcode);
-
-        if ($_ENV['enable_reg_im'] === true) {
-            $imtype  = $request->getParam('im_type');
-            $imvalue = $request->getParam('im_value');
-            if ($imtype == '' || $imvalue == '') {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '请填上你的联络方式'
-                ]);
+            if ($passwd != $repasswd) {
+                throw new \Exception('两次输入的密码不相符');
             }
-            $user = User::where('im_value', $imvalue)->where('im_type', $imtype)->first();
-            if ($user != null) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '此联络方式已注册'
-                ]);
+            if ($reg_mode == 'close') {
+                throw new \Exception('未开放注册');
             }
-        } else {
-            $imtype  = 1;
-            $imvalue = '';
-        }
-
-        if (Setting::obtain('enable_reg_captcha') == true) {
-            $ret = Captcha::verify($request->getParams());
-            if (!$ret) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '系统无法接受您的验证结果,请刷新页面后重试。'
-                ]);
+            if ($reg_mode == 'invite' && $code == '') {
+                throw new \Exception('仅开放邀请注册,请填写邀请码');
             }
-        }
-
-        // check email format
-        $check_res = Check::isEmailLegal($email);
-        if ($check_res['ret'] == 0) {
-            return $response->withJson($check_res);
-        }
-        // check email
-        $user = User::where('email', $email)->first();
-        if ($user != null) {
-            return $response->withJson([
-                'ret' => 0,
-                'msg' => '邮箱已经被注册了'
-            ]);
-        }
-
-        if (Setting::obtain('reg_email_verify')) {
-            $mailcount = EmailVerify::where('email', '=', $email)->where('code', '=', $emailcode)->where('expire_in', '>', time())->first();
-            if ($mailcount == null) {
-                return $response->withJson([
-                    'ret' => 0,
-                    'msg' => '您的邮箱验证码不正确'
-                ]);
+            if ($reg_mode == 'invite') {
+                $reg_invite_code = InviteCode::where('code', $code)->first();
+                if ($reg_invite_code == null) {
+                    throw new \Exception('没有找到这个邀请码');
+                }
+                $invite_user = User::where('id', $reg_invite_code->user_id)->first();
+                if ($invite_user == null) {
+                    throw new \Exception('邀请人不存在');
+                }
+                if ($invite_user->invite_num == 0) {
+                    throw new \Exception('邀请码可用次数不足');
+                }
+            }
+            if ($_ENV['enable_reg_im']) {
+                $imtype = $request->getParam('im_type');
+                $imvalue = $request->getParam('im_value');
+                if ($imtype == '0' || $imtype != '1' && $imtype != '2' && $imtype != '4' && $imtype != '5' || $imvalue == '') {
+                    throw new \Exception('选择社交软件并填写社交账户');
+                }
+                $imtype_exist = User::where('im_value', $imvalue)
+                ->where('im_type', $imtype)
+                ->first();
+                if ($imtype_exist != null) {
+                    throw new \Exception('此社交账户已被使用');
+                }
+            } else {
+                $imtype = 1;
+                $imvalue = '';
+            }
+            $user = User::where('email', $email)->first();
+            if ($user != null) {
+                throw new \Exception('此邮箱已注册');
+            }
+            if (Setting::obtain('reg_email_verify')) {
+                $mailcount = EmailVerify::where('email', $email)
+                ->where('code', $emailcode)
+                ->where('expire_in', '>', time())
+                ->first();
+                if ($mailcount == null) {
+                    throw new \Exception('邮箱验证码不正确');
+                }
             }
-        }
-
-        // check pwd length
-        if (strlen($passwd) < 8) {
-            return $response->withJson([
-                'ret' => 0,
-                'msg' => '密码请大于8位'
-            ]);
-        }
 
-        // check pwd re
-        if ($passwd != $repasswd) {
+            self::register_helper($name, $email, $passwd, $code, $imtype, $imvalue, 0);
+        } catch (\Exception $e) {
             return $response->withJson([
                 'ret' => 0,
-                'msg' => '两次密码输入不符'
+                'msg' => $e->getMessage()
             ]);
         }
 
-        if (Setting::obtain('reg_email_verify')) {
-            EmailVerify::where('email', $email)->delete();
+        if ($reg_mode == 'invite') {
+            // 仅在仅允许邀请注册的情况下扣减邀请码次数
+            $invite_user->invite_num -= 1;
+            $invite_user->save();
         }
 
-        return $response->withJson(
-            $this->register_helper($name, $email, $passwd, $code, $imtype, $imvalue, 0)
-        );
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function logout($request, $response, $next)
-    {
-        Auth::logout();
-        return $response->withStatus(302)->withHeader('Location', '/auth/login');
-    }
-
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function qrcode_check($request, $response, $args)
-    {
-        $token  = $request->getParam('token');
-        $number = $request->getParam('number');
-        $user   = Auth::getUser();
-        if ($user->isLogin) {
-            return $response->withJson([
-                'ret' => 0
-            ]);
-        }
-        if ($_ENV['enable_telegram_login'] === true) {
-            $ret = TelegramSessionManager::check_login_session($token, $number);
-            $res['ret'] = $ret;
-            return $response->withJson($res);
-        }
         return $response->withJson([
-            'ret' => 0
+            'ret' => 1,
+            'msg' => '注册成功'
         ]);
     }
 
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    public function telegram_oauth($request, $response, $args)
+    public function register_helper($name, $email, $passwd, $code, $imtype, $imvalue, $telegram_id)
     {
-        if ($_ENV['enable_telegram_login'] === true) {
-            $auth_data = $request->getQueryParams();
-            if ($this->telegram_oauth_check($auth_data) === true) { // Looks good, proceed.
-                $telegram_id = $auth_data['id'];
-                $user        = User::query()->where('telegram_id', $telegram_id)->firstOrFail(); // Welcome Back :)
-                if ($user == null) {
-                    return $this->view()
-                        ->assign('title', '您需要先进行邮箱注册后绑定Telegram才能使用授权登录')
-                        ->assign('message', '很抱歉带来的不便,请重新试试')
-                        ->assign('redirect', '/auth/login')
-                        ->display('telegram_error.tpl');
-                }
-                Auth::login($user->id, 3600);
-
-                // 记录登录成功
-                $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
-
-                // 登陆成功!
-                return $this->view()
-                    ->assign('title', '登录成功')
-                    ->assign('message', '正在前往仪表盘')
-                    ->assign('redirect', '/user')
-                    ->display('telegram_success.tpl');
-            }
-            // 验证失败
-            return $this->view()
-                ->assign('title', '登陆超时或非法构造信息')
-                ->assign('message', '很抱歉带来的不便,请重新试试')
-                ->assign('redirect', '/auth/login')
-                ->display('telegram_error.tpl');
+        $ga = new GA();
+        $user = new User();
+        $antiXss = new AntiXSS();
+
+        $user->money = $_ENV['reg_money'];
+        $user->email = $email;
+        $user->im_type = $imtype;
+        $user->im_value = $antiXss->xss_clean($imvalue);
+        $user->user_name = $antiXss->xss_clean($name);
+        $user->port = Tools::getAvPort();
+        $user->pass = Hash::passwordHash($passwd); // 登录密码
+        $user->passwd = Tools::genRandomChar(16); // ss 连接密码
+        $user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $email . '|' . time());
+        $user->t = 0;
+        $user->u = 0;
+        $user->d = 0;
+        $user->transfer_enable = 0;
+        $user->invite_num = $_ENV['reg_invite_num'];
+        $user->auto_reset_day = 0;
+        $user->auto_reset_bandwidth = 0;
+        $user->sendDailyMail = 0; // 默认不发送
+        $user->obfs = 'plain';
+        $user->method = 'rc4-md5';
+        $user->protocol = 'origin';
+        $user->obfs_param = 'world.taobao.com';
+        $user->protocol_param = '';
+        $user->forbidden_ip = $_ENV['reg_forbidden_ip'];
+        $user->forbidden_port = $_ENV['reg_forbidden_port'];
+        if ($telegram_id) {
+            $user->telegram_id = $telegram_id;
         }
-        return $response->withRedirect('/404');
+        $user->ga_enable = 0;
+        $user->ga_token = $ga->createSecret();
+        $user->node_connector = 0;
+        $user->node_speedlimit = 0;
+        $user->class = 0;
+        $user->expire_in = date('Y-m-d H:i:s', time());
+        $user->class_expire = date('Y-m-d H:i:s', time());
+        $user->reg_date = date('Y-m-d H:i:s');
+        $user->reg_ip = $_SERVER['REMOTE_ADDR'];
+        $user->theme = $_ENV['theme'];
+        $groups = explode(',', $_ENV['random_group']);
+        $user->node_group = $groups[array_rand($groups)];
+        $user->save();
+
+        Auth::login($user->id, 3600);
+        $user->collectLoginIP($_SERVER['REMOTE_ADDR']);
     }
 
-    /**
-     * @param Request   $request
-     * @param Response  $response
-     * @param array     $args
-     */
-    private function telegram_oauth_check($auth_data)
+    public function logout($request, $response, $next)
     {
-        $check_hash = $auth_data['hash'];
-        $bot_token  = $_ENV['telegram_token'];
-        unset($auth_data['hash']);
-        $data_check_arr = [];
-        foreach ($auth_data as $key => $value) {
-            $data_check_arr[] = $key . '=' . $value;
-        }
-        sort($data_check_arr);
-        $data_check_string = implode("\n", $data_check_arr);
-        $secret_key        = hash('sha256', $bot_token, true);
-        $hash              = hash_hmac('sha256', $data_check_string, $secret_key);
-        if (strcmp($hash, $check_hash) !== 0) {
-            return false; // Bad Data :(
-        }
-
-        if ((time() - $auth_data['auth_date']) > 300) { // Expire @ 5mins
-            return false;
-        }
-
-        return true; // Good to Go
+        Auth::logout();
+        return $response->withStatus(302)->withHeader('Location', '/auth/login');
     }
 }