diff --git a/catchAdmin/login/controller/Index.php b/catchAdmin/login/controller/Index.php index e45d367..ed339f9 100644 --- a/catchAdmin/login/controller/Index.php +++ b/catchAdmin/login/controller/Index.php @@ -1,10 +1,11 @@ login($request->param()) ? + return Auth::login($request->param()) ? CatchResponse::success('', '登录成功') : CatchResponse::success('', '登录失败'); } @@ -43,10 +44,22 @@ class Index extends CatchController */ public function logout(): bool { - if ((new Auth())->logout()) { + if (Auth::logout()) { return redirect(url('login')); } return false; } + + /** + * + * @time 2019年12月12日 + * @param Captcha $captcha + * @param null $config + * @return \think\Response + */ + public function captcha(Captcha $captcha, $config = null): \think\Response + { + return $captcha->create($config); + } } \ No newline at end of file diff --git a/catchAdmin/login/request/LoginRequest.php b/catchAdmin/login/request/LoginRequest.php index 392d3c5..a8b709d 100644 --- a/catchAdmin/login/request/LoginRequest.php +++ b/catchAdmin/login/request/LoginRequest.php @@ -9,7 +9,7 @@ class LoginRequest extends CatchRequest { // TODO: Implement rules() method. return [ - 'name|用户名' => 'require|max:25', + 'email|用户名' => 'email', 'password|密码' => 'require', // 'captcha|验证码' => 'require|captcha' ]; diff --git a/catchAdmin/login/route.php b/catchAdmin/login/route.php index 669d695..10665ea 100644 --- a/catchAdmin/login/route.php +++ b/catchAdmin/login/route.php @@ -1,8 +1,11 @@ get('login', '\catchAdmin\login\controller\Index/index'); +$router->get('login', '\catchAdmin\login\controller\Index@index'); # 登入 -$router->post('login', '\catchAdmin\login\controller\Index/login'); +$router->post('login', '\catchAdmin\login\controller\Index@login'); # 登出 -$router->post('logout', '\catchAdmin\login\controller\Index/logout'); +$router->post('logout', '\catchAdmin\login\controller\Index@logout'); +# 验证码 +$router->get('catch/captcha/[:config]','\catchAdmin\login\controller\Index@captcha'); + diff --git a/catchAdmin/login/view/index.html b/catchAdmin/login/view/index.html index 8e44f37..4307043 100644 --- a/catchAdmin/login/view/index.html +++ b/catchAdmin/login/view/index.html @@ -38,8 +38,8 @@