diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index deaad28df..4ce95414a 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -16,6 +16,7 @@ namespace app\admin\controller; use think\admin\Controller; +use think\admin\extend\CodeExtend; use think\admin\service\AdminService; use think\admin\service\CaptchaService; use think\admin\service\SystemService; @@ -41,7 +42,9 @@ class Login extends Controller $this->redirect(url('@admin')->build()); } else { $this->title = '系统登录'; - $this->captcha = CaptchaService::instance()->getAttrs(); + $this->captcha_type = 'login_captcha'; + $this->captcha_token = CodeExtend::uniqidDate(18); + $this->app->session->set($this->captcha_type, $this->captcha_token); $this->devmode = SystemService::instance()->checkRunMode('dev'); $this->fetch(); } @@ -52,7 +55,7 @@ class Login extends Controller 'password.require' => '登录密码不能为空!', 'password.min:4' => '登录密码长度不能少于4位有效字符!', 'verify.require' => '图形验证码不能为空!', - 'uniqid.require' => '图形验证标识不能为空!' + 'uniqid.require' => '图形验证标识不能为空!', ]); if (!CaptchaService::instance()->check($data['verify'], $data['uniqid'])) { $this->error('图形验证码验证失败,请重新输入!'); @@ -86,10 +89,14 @@ class Login extends Controller public function captcha() { $image = CaptchaService::instance(); - $this->success('生成验证码成功', [ - 'image' => $image->getData(), - 'uniqid' => $image->getUniqid(), - ]); + $this->type = input('type', 'captcha-type'); + $this->token = input('token', 'captcha-token'); + $captcha = ['image' => $image->getData(), 'uniqid' => $image->getUniqid()]; + if ($this->app->session->get($this->type) === $this->token) { + $captcha['code'] = $image->getCode(); + $this->app->session->delete($this->type); + } + $this->success('生成验证码成功', $captcha); } /** diff --git a/app/admin/view/login/index.html b/app/admin/view/login/index.html index 1420e049e..888602712 100644 --- a/app/admin/view/login/index.html +++ b/app/admin/view/login/index.html @@ -28,10 +28,9 @@
  • - img - +
  • diff --git a/composer.lock b/composer.lock index eaef0ba4d..8f0f8b167 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "905a9a503897919ded0a61b84c5af6ac763fc736" + "reference": "f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/905a9a503897919ded0a61b84c5af6ac763fc736", - "reference": "905a9a503897919ded0a61b84c5af6ac763fc736", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80", + "reference": "f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2019-12-25T09:17:55+00:00" + "time": "2019-12-27T01:48:44+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 8b29bbaae..5631e8556 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "905a9a503897919ded0a61b84c5af6ac763fc736" + "reference": "f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/905a9a503897919ded0a61b84c5af6ac763fc736", - "reference": "905a9a503897919ded0a61b84c5af6ac763fc736", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80", + "reference": "f231c9bb248fa6c1bd0f5e7c569f350e98c7ac80", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2019-12-25T09:17:55+00:00", + "time": "2019-12-27T01:48:44+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 150b4c5af..fd4914a94 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/Service.php b/vendor/zoujingli/think-library/src/Service.php index 13025b9ac..6520b49e6 100644 --- a/vendor/zoujingli/think-library/src/Service.php +++ b/vendor/zoujingli/think-library/src/Service.php @@ -19,7 +19,7 @@ use think\App; use think\Container; /** - * 自定义服务接口 + * 自定义服务基类 * Class Service * @package think\admin */ diff --git a/vendor/zoujingli/think-library/src/Storage.php b/vendor/zoujingli/think-library/src/Storage.php index e22cd70c4..f38d98c0a 100644 --- a/vendor/zoujingli/think-library/src/Storage.php +++ b/vendor/zoujingli/think-library/src/Storage.php @@ -23,13 +23,13 @@ use think\Container; * Class Storage * @package think\admin * @method array info($name, $safe = false) static 文件存储信息 - * @method array set($name, $file, $safe = false) static 文件储存 + * @method array set($name, $file, $safe = false) static 储存文件 * @method string get($name, $safe = false) static 读取文件内容 * @method string url($name, $safe = false) static 获取文件链接 * @method string path($name, $safe = false) static 文件存储路径 * @method boolean del($name, $safe = false) static 删除存储文件 - * @method boolean has($name, $safe = false) static 检查文件是否存在 - * @method string upload() static 上传目录地址 + * @method boolean has($name, $safe = false) static 检查是否存在 + * @method string upload() static 获取上传地址 */ abstract class Storage {