|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
+use app\admin\validate\AdminUser as AdminUserValidate;
|
|
|
use app\common\model\mysql\AdminUser;
|
|
|
use think\facade\View;
|
|
|
|
|
@@ -17,7 +18,7 @@ class Login extends AdminBase
|
|
|
public function initialize()
|
|
|
{
|
|
|
if ($this->isLogin()) {
|
|
|
- return $this->redirect(url('index/index'),302);
|
|
|
+ return $this->redirect(url('index/index'), 302);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -42,14 +43,24 @@ class Login extends AdminBase
|
|
|
$username = $this->request->param('username', '', 'trim');
|
|
|
$password = $this->request->param('password', '', 'trim');
|
|
|
$captcha = $this->request->param('captcha', '', 'trim');
|
|
|
- if (empty($username) || empty($password) || empty($captcha)) {
|
|
|
- return show(config('status.error'), '参数不能为空');
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'username' => $username,
|
|
|
+ 'password' => $password,
|
|
|
+ 'captcha' => $captcha,
|
|
|
+ ];
|
|
|
+ $validate = new AdminUserValidate();
|
|
|
+ if ($validate->check($data)) {
|
|
|
+ return show(config('status.error'), $validate->getError());
|
|
|
}
|
|
|
+// if (empty($username) || empty($password) || empty($captcha)) {
|
|
|
+// return show(config('status.error'), '参数不能为空');
|
|
|
+// }
|
|
|
// 验证码校验
|
|
|
- if (!captcha_check($captcha)) {
|
|
|
- // 验证码校验失败
|
|
|
- return show(config('status.error'), '验证码不正确');
|
|
|
- }
|
|
|
+// if (!captcha_check($captcha)) {
|
|
|
+// // 验证码校验失败
|
|
|
+// return show(config('status.error'), '验证码不正确');
|
|
|
+// }
|
|
|
|
|
|
try {
|
|
|
$adminUserObj = new AdminUser();
|