|
@@ -12,6 +12,7 @@ use app\common\until\Until;
|
|
|
use think\captcha\Captcha;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
+use think\facade\Cache;
|
|
|
use think\Request;
|
|
|
|
|
|
class Admin extends BaseController {
|
|
@@ -153,6 +154,7 @@ class Admin extends BaseController {
|
|
|
* @OA\Property(description="登入账号", property="account", type="string", default="admin"),
|
|
|
* @OA\Property(description="登入密码", property="password", type="string", default="123456"),
|
|
|
* @OA\Property(description="验证码", property="code", type="string", default="akjs"),
|
|
|
+ * @OA\Property(description="生成验证码时的唯一码", property="uniqueKey", type="string", default="sdafsdfsd"),
|
|
|
* required={"account","password","code"})
|
|
|
* )
|
|
|
* ),
|
|
@@ -164,13 +166,15 @@ class Admin extends BaseController {
|
|
|
$rule = [
|
|
|
'account|用户名' => 'require',
|
|
|
'password|内容' => 'require',
|
|
|
- 'code|验证码' => 'require'
|
|
|
+ 'code|验证码' => 'require',
|
|
|
+ 'uniqueKey|唯一码' => 'require'
|
|
|
];
|
|
|
Until::check($rule, $input);
|
|
|
- if( !captcha_check($input['code'] )) {
|
|
|
+ if( strtolower($input['code']) != strtolower(Cache::get($input['uniqueKey']))) {
|
|
|
// 验证失败
|
|
|
throw new ApiException('验证码错误');
|
|
|
}
|
|
|
+ Cache::rm('uniqueKey');
|
|
|
$model = (new AdminModel());
|
|
|
$where[] = ['a.account', '=', $input['account']];
|
|
|
$where[] = ['a.password', '=', $input['password']];
|
|
@@ -247,14 +251,15 @@ class Admin extends BaseController {
|
|
|
* @OA\GET(path="/api/Admin/verifyImg",
|
|
|
* tags={"管理员管理"},
|
|
|
* summary="生成验证码",
|
|
|
+ * @OA\Parameter(name="uniqueKey", in="query", description="唯一id", @OA\Schema(type="string",default="1121212")),
|
|
|
* @OA\RequestBody(
|
|
|
* ),
|
|
|
* @OA\Response(response="200", description="请求成功")
|
|
|
* )
|
|
|
*/
|
|
|
- public function verifyImg() {
|
|
|
+ public function verifyImg($uniqueKey) {
|
|
|
$captcha = new Captcha();
|
|
|
- return $captcha->entry();
|
|
|
+ return $captcha->entry('',$uniqueKey);
|
|
|
}
|
|
|
|
|
|
/**
|