mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate & 修改登录验证码
This commit is contained in:
parent
27e8bc8b52
commit
a0175b4430
@ -42,10 +42,12 @@ class Login extends Controller
|
|||||||
$this->redirect(url('@admin')->build());
|
$this->redirect(url('@admin')->build());
|
||||||
} else {
|
} else {
|
||||||
$this->title = '系统登录';
|
$this->title = '系统登录';
|
||||||
$this->captcha_type = 'login_captcha';
|
$this->captchaType = 'loginCaptcha';
|
||||||
$this->captcha_token = CodeExtend::uniqidDate(18);
|
$this->captchaToken = CodeExtend::uniqidDate(18);
|
||||||
$this->app->session->set($this->captcha_type, $this->captcha_token);
|
|
||||||
$this->devmode = SystemService::instance()->checkRunMode('dev');
|
$this->devmode = SystemService::instance()->checkRunMode('dev');
|
||||||
|
if (!$this->app->session->get('login_input_session_error')) {
|
||||||
|
$this->app->session->set($this->captchaType, $this->captchaToken);
|
||||||
|
}
|
||||||
$this->fetch();
|
$this->fetch();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -64,21 +66,24 @@ class Login extends Controller
|
|||||||
$map = ['username' => $data['username'], 'is_deleted' => '0'];
|
$map = ['username' => $data['username'], 'is_deleted' => '0'];
|
||||||
$user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
|
$user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
|
$this->app->session->set("login_input_session_error", true);
|
||||||
$this->error('登录账号或密码错误,请重新输入!');
|
$this->error('登录账号或密码错误,请重新输入!');
|
||||||
}
|
}
|
||||||
if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
|
if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
|
||||||
|
$this->app->session->set("login_input_session_error", true);
|
||||||
$this->error('登录账号或密码错误,请重新输入!');
|
$this->error('登录账号或密码错误,请重新输入!');
|
||||||
}
|
}
|
||||||
if (empty($user['status'])) {
|
if (empty($user['status'])) {
|
||||||
$this->error('账号已经被禁用,请联系管理员!');
|
$this->error('账号已经被禁用,请联系管理员!');
|
||||||
}
|
}
|
||||||
|
$this->app->session->delete("login_input_session_error");
|
||||||
$this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
|
$this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
|
||||||
'login_ip' => $this->app->request->ip(),
|
'login_ip' => $this->app->request->ip(),
|
||||||
'login_at' => $this->app->db->raw('now()'),
|
'login_at' => $this->app->db->raw('now()'),
|
||||||
'login_num' => $this->app->db->raw('login_num+1'),
|
'login_num' => $this->app->db->raw('login_num+1'),
|
||||||
]);
|
]);
|
||||||
|
sysoplog('用户登录', '登录系统后台成功');
|
||||||
$this->app->session->set('user', $user);
|
$this->app->session->set('user', $user);
|
||||||
sysoplog('用户登录', "登录系统后台成功");
|
|
||||||
$this->success('登录成功', url('@admin')->build());
|
$this->success('登录成功', url('@admin')->build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<i class="layui-icon layui-icon-picture-fine"></i>
|
<i class="layui-icon layui-icon-picture-fine"></i>
|
||||||
<input class="layui-input" required pattern="^\S{4,}$" name="verify" maxlength="4" autocomplete="off" placeholder="验证码" title="请输入验证码">
|
<input class="layui-input" required pattern="^\S{4,}$" name="verify" maxlength="4" autocomplete="off" placeholder="验证码" title="请输入验证码">
|
||||||
</label>
|
</label>
|
||||||
<label data-captcha="{:url('admin/login/captcha',[],false)}" data-field-verify="verify" data-field-uniqid="uniqid" data-captcha-type="{$captcha_type}" data-captcha-token="{$captcha_token}"></label>
|
<label data-captcha="{:url('admin/login/captcha',[],false)}" data-field-verify="verify" data-field-uniqid="uniqid" data-captcha-type="{$captchaType}" data-captcha-token="{$captchaToken}"></label>
|
||||||
</li>
|
</li>
|
||||||
<li class="text-center padding-top-20">
|
<li class="text-center padding-top-20">
|
||||||
<button type="submit" class="layui-btn layui-disabled full-width" data-form-loaded="立即登入">正在载入</button>
|
<button type="submit" class="layui-btn layui-disabled full-width" data-form-loaded="立即登入">正在载入</button>
|
||||||
|
10
composer.lock
generated
10
composer.lock
generated
@ -498,7 +498,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/options-resolver",
|
"name": "symfony/options-resolver",
|
||||||
"version": "v3.4.38",
|
"version": "v3.4.39",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/options-resolver.git",
|
"url": "https://github.com/symfony/options-resolver.git",
|
||||||
@ -909,12 +909,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b"
|
"reference": "e031f91b1c3d64b190f202e6e913bfa301d2ce14"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e031f91b1c3d64b190f202e6e913bfa301d2ce14",
|
||||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b",
|
"reference": "e031f91b1c3d64b190f202e6e913bfa301d2ce14",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -958,7 +958,7 @@
|
|||||||
],
|
],
|
||||||
"description": "ThinkPHP v6.0 Development Library",
|
"description": "ThinkPHP v6.0 Development Library",
|
||||||
"homepage": "http://framework.thinkadmin.top",
|
"homepage": "http://framework.thinkadmin.top",
|
||||||
"time": "2020-03-26T10:28:21+00:00"
|
"time": "2020-04-01T08:17:31+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zoujingli/wechat-developer",
|
"name": "zoujingli/wechat-developer",
|
||||||
|
@ -33,28 +33,23 @@ $(function () {
|
|||||||
|
|
||||||
/*! 登录图形验证码刷新 */
|
/*! 登录图形验证码刷新 */
|
||||||
$body.on('click', '[data-captcha]', function () {
|
$body.on('click', '[data-captcha]', function () {
|
||||||
var type, token, verify, uniqid, action, $that = $(this);
|
var $that = $(this), $form = $that.parents('form');
|
||||||
action = this.getAttribute('data-captcha') || location.href;
|
var action = this.getAttribute('data-captcha') || location.href;
|
||||||
if (action.length < 5) return $.msg.tips('请设置验证码请求地址');
|
if (action.length < 5) return $.msg.tips('请设置验证码请求及验证地址');
|
||||||
type = this.getAttribute('data-captcha-type') || 'captcha-type';
|
var type = this.getAttribute('data-captcha-type') || 'captcha-type';
|
||||||
token = this.getAttribute('data-captcha-token') || 'captcha-token';
|
var token = this.getAttribute('data-captcha-token') || 'captcha-token';
|
||||||
uniqid = this.getAttribute('data-field-uniqid') || 'uniqid';
|
var uniqid = this.getAttribute('data-field-uniqid') || 'captcha-uniqid';
|
||||||
verify = this.getAttribute('data-field-verify') || 'verify';
|
var verify = this.getAttribute('data-field-verify') || 'captcha-verify';
|
||||||
$.form.load(action, {type: type, token: token}, 'post', function (ret) {
|
$.form.load(action, {type: type, token: token}, 'post', function (ret) {
|
||||||
if (ret.code) {
|
if (ret.code) {
|
||||||
$that.html('');
|
$that.html('<img alt="img" src="' + ret.data.image + '"><input type="hidden">').find('input').attr('name', uniqid).val(ret.data.uniqid || '');
|
||||||
$that.append($('<img alt="img" src="">').attr('src', ret.data.image));
|
$form.find('[name="' + verify + '"]').attr('value', ret.data.code || '').val(ret.data.code || '');
|
||||||
$that.append($('<input type="hidden">').attr('name', uniqid).val(ret.data.uniqid));
|
return (ret.data.code || $form.find('.verify.layui-hide').removeClass('layui-hide')), false;
|
||||||
if (ret.data.code) {
|
|
||||||
$that.parents('form').find('[name=' + verify + ']').attr('value', ret.data.code);
|
|
||||||
} else {
|
|
||||||
$that.parents('form').find('[name=' + verify + ']').attr('value', '');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*! 初始化登录图形 */
|
||||||
$('[data-captcha]').map(function () {
|
$('[data-captcha]').map(function () {
|
||||||
$(this).trigger('click')
|
$(this).trigger('click')
|
||||||
});
|
});
|
||||||
|
12
vendor/composer/installed.json
vendored
12
vendor/composer/installed.json
vendored
@ -507,8 +507,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/options-resolver",
|
"name": "symfony/options-resolver",
|
||||||
"version": "v3.4.38",
|
"version": "v3.4.39",
|
||||||
"version_normalized": "3.4.38.0",
|
"version_normalized": "3.4.39.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/options-resolver.git",
|
"url": "https://github.com/symfony/options-resolver.git",
|
||||||
@ -935,12 +935,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b"
|
"reference": "e031f91b1c3d64b190f202e6e913bfa301d2ce14"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e031f91b1c3d64b190f202e6e913bfa301d2ce14",
|
||||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b",
|
"reference": "e031f91b1c3d64b190f202e6e913bfa301d2ce14",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -956,7 +956,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2020-03-26T10:28:21+00:00",
|
"time": "2020-04-01T08:17:31+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2020-03-27 10:03:07
|
// This file is automatically generated at:2020-04-02 11:17:50
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\app\\Service',
|
0 => 'think\\app\\Service',
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
namespace think\admin\service;
|
namespace think\admin\service;
|
||||||
|
|
||||||
|
use think\admin\extend\CodeExtend;
|
||||||
use think\admin\extend\HttpExtend;
|
use think\admin\extend\HttpExtend;
|
||||||
use think\admin\Service;
|
use think\admin\Service;
|
||||||
|
|
||||||
@ -35,13 +36,7 @@ class ExpressService extends Service
|
|||||||
* 网络请求参数
|
* 网络请求参数
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $options;
|
protected $config;
|
||||||
|
|
||||||
/**
|
|
||||||
* 会话Cookie文件
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $cookies = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快递服务初始化
|
* 快递服务初始化
|
||||||
@ -49,17 +44,10 @@ class ExpressService extends Service
|
|||||||
*/
|
*/
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
$this->cookies = "{$this->app->getRuntimePath()}_express_cookie.txt";
|
$clentip = $this->app->request->ip();
|
||||||
if (file_exists($this->cookies) && filemtime($this->cookies) + 10 < time()) {
|
$cookies = "{$this->app->getRootPath()}runtime/.express.cookie";
|
||||||
@unlink($this->cookies);
|
$headers = ['Host:express.baidu.com', "CLIENT-IP:{$clentip}", "X-FORWARDED-FOR:{$clentip}"];
|
||||||
}
|
$this->config = ['cookie_file' => $cookies, 'headers' => $headers];
|
||||||
$this->options = [
|
|
||||||
'cookie_file' => $this->cookies, 'headers' => [
|
|
||||||
'Host' => 'express.baidu.com',
|
|
||||||
'CLIENT-IP' => $this->app->request->ip(),
|
|
||||||
'X-FORWARDED-FOR' => $this->app->request->ip(),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$this->token = $this->getExpressToken();
|
$this->token = $this->getExpressToken();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -93,7 +81,7 @@ class ExpressService extends Service
|
|||||||
public function getExpressList()
|
public function getExpressList()
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
if (preg_match('/"currentData":.*?\[(.*?)\],/', $this->getWapBaiduHtml(), $matches)) {
|
if (preg_match('/"currentData":.*?\[(.*?)],/', $this->getWapBaiduHtml(), $matches)) {
|
||||||
foreach (json_decode("[{$matches['1']}]") as $item) $data[$item->value] = $item->text;
|
foreach (json_decode("[{$matches['1']}]") as $item) $data[$item->value] = $item->text;
|
||||||
unset($data['_auto']);
|
unset($data['_auto']);
|
||||||
return $data;
|
return $data;
|
||||||
@ -111,9 +99,9 @@ class ExpressService extends Service
|
|||||||
*/
|
*/
|
||||||
private function doExpress($code, $number)
|
private function doExpress($code, $number)
|
||||||
{
|
{
|
||||||
$uniqid = strtr(uniqid(), '.', '');
|
$qid = CodeExtend::uniqidNumber(19, '7740');
|
||||||
$url = "https://express.baidu.com/express/api/express?tokenV2={$this->token}&appid=4001&nu={$number}&com={$code}&qid={$uniqid}&new_need_di=1&source_xcx=0&vcode=&token=&sourceId=4155&cb=callback";
|
$url = "https://express.baidu.com/express/api/express?tokenV2={$this->token}&appid=4001&nu={$number}&com={$code}&qid={$qid}&new_need_di=1&source_xcx=0&vcode=&token=&sourceId=4155&cb=callback";
|
||||||
return json_decode(str_replace('/**/callback(', '', trim(HttpExtend::get($url, [], $this->options), ')')), true);
|
return json_decode(str_replace('/**/callback(', '', trim(HttpExtend::get($url, [], $this->config), ')')), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +126,7 @@ class ExpressService extends Service
|
|||||||
{
|
{
|
||||||
$content = $this->app->cache->get('express_kuaidi_html');
|
$content = $this->app->cache->get('express_kuaidi_html');
|
||||||
while (empty($content) || stristr($content, '百度安全验证') > -1 || stripos($content, 'tokenV2') === -1) {
|
while (empty($content) || stristr($content, '百度安全验证') > -1 || stripos($content, 'tokenV2') === -1) {
|
||||||
$content = HttpExtend::get('https://m.baidu.com/s?word=快递查询&rnd=' . uniqid(), [], $this->options);
|
$content = HttpExtend::get('https://m.baidu.com/s?word=快递查询&rand=' . microtime(true), [], $this->config);
|
||||||
}
|
}
|
||||||
$this->app->cache->set('express_kuaidi_html', $content, 30);
|
$this->app->cache->set('express_kuaidi_html', $content, 30);
|
||||||
return $content;
|
return $content;
|
||||||
|
@ -181,7 +181,7 @@ class QueueService extends Service
|
|||||||
return $this->progress($status, $message, $progress);
|
return $this->progress($status, $message, $progress);
|
||||||
}
|
}
|
||||||
if (is_numeric($status)) $data['status'] = intval($status);
|
if (is_numeric($status)) $data['status'] = intval($status);
|
||||||
if (is_numeric($progress)) $progress = sprintf("%.2f", $progress);
|
if (is_numeric($progress)) $progress = str_pad(sprintf("%.2f", $progress), 6, "0", STR_PAD_LEFT);
|
||||||
if (is_string($message) && is_null($progress)) {
|
if (is_string($message) && is_null($progress)) {
|
||||||
$data['message'] = $message;
|
$data['message'] = $message;
|
||||||
$data['history'][] = ['message' => $message, 'progress' => $data['progress'], 'datetime' => date('Y-m-d H:i:s')];
|
$data['history'][] = ['message' => $message, 'progress' => $data['progress'], 'datetime' => date('Y-m-d H:i:s')];
|
||||||
|
@ -176,7 +176,7 @@ class SystemService extends Service
|
|||||||
*/
|
*/
|
||||||
public function putDebug($data, $new = false, $file = null)
|
public function putDebug($data, $new = false, $file = null)
|
||||||
{
|
{
|
||||||
if (is_null($file)) $file = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . date('Ymd') . '.txt';
|
if (is_null($file)) $file = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . date('Ymd') . '.log';
|
||||||
$str = (is_string($data) ? $data : ((is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true))) . PHP_EOL;
|
$str = (is_string($data) ? $data : ((is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true))) . PHP_EOL;
|
||||||
$new ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND);
|
$new ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user