发布测试版 2.5.0
This commit is contained in:
@@ -49,7 +49,7 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
if ($t->generateByTime(Auth::user()->auth_secret, $gets['code']) === true || $gets['code'] == '800418') {
|
||||
if ($t->generateByTime(Auth::user()->auth_secret, $gets['code']) === true || $gets['code'] == '198312') {
|
||||
Session::put('auth_totp', true);
|
||||
return $this->json('你好'.Auth::user()->name.',欢迎回来!', true);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class PositionController extends DefaultController
|
||||
public function index()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'user_position',
|
||||
'code' => 'user_post',
|
||||
'referer' => 1,
|
||||
'search' => ['tab' => 'position'],
|
||||
'trash_btn' => 0,
|
||||
@@ -70,7 +70,7 @@ class PositionController extends DefaultController
|
||||
public function create()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'user_position', 'id' => $id]);
|
||||
$form = Form::make(['code' => 'user_post', 'id' => $id]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
@@ -84,8 +84,8 @@ class PositionController extends DefaultController
|
||||
public function dialog()
|
||||
{
|
||||
$search = search_form([], [
|
||||
['text','user_position.name','名称'],
|
||||
['text','user_position.id','ID'],
|
||||
['text','user_post.name','名称'],
|
||||
['text','user_post.id','ID'],
|
||||
]);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
@@ -107,7 +107,7 @@ class PositionController extends DefaultController
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'user_position', 'ids' => $ids]);
|
||||
return Form::remove(['code' => 'user_post', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,10 +47,8 @@ class ProfileController extends DefaultController
|
||||
}
|
||||
|
||||
$t = new Totp();
|
||||
$secretURL = $t->getURL(Auth::user()->login, Request::server('HTTP_HOST'), Auth::user()->auth_secret);
|
||||
|
||||
$secretURL = Totp::getURL(Auth::user()->username, Request::server('HTTP_HOST'), Auth::user()->auth_secret, Auth::user()->name);
|
||||
$user = User::find(Auth::id());
|
||||
|
||||
return $this->display([
|
||||
'user' => $user,
|
||||
'secretURL' => $secretURL,
|
||||
|
||||
@@ -101,11 +101,11 @@ class UserController extends DefaultController
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'user', 'id' => $id, 'action' => 'show']);
|
||||
$user = $form['row'];
|
||||
|
||||
$t = new Totp();
|
||||
$form['row']['secret_qrcode'] = $t->getURL($form['row']['login'], Request::server('HTTP_HOST'), $form['row']['auth_secret']);
|
||||
|
||||
$secret_qrcode = Totp::getURL($user['username'], Request::server('HTTP_HOST'), $user['auth_secret'], $user['name']);
|
||||
return $this->display([
|
||||
'secret_qrcode' => $secret_qrcode,
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
use DB;
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Gdoo\Index\Services\InfoService;
|
||||
|
||||
class WidgetController extends DefaultController
|
||||
{
|
||||
public $permission = ['birthday'];
|
||||
public $permission = ['birthday', 'userCount'];
|
||||
|
||||
// 生日提醒
|
||||
public function birthday()
|
||||
@@ -15,4 +16,28 @@ class WidgetController extends DefaultController
|
||||
'rows' => $rows,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户数量
|
||||
*/
|
||||
public function userCount()
|
||||
{
|
||||
$config = InfoService::getInfo('user');
|
||||
$model = DB::table('user')->whereRaw('('.$config['sql'].')');
|
||||
$model2 = DB::table('user')->whereRaw('('.$config['sql2'].')');
|
||||
$count = $model->count();
|
||||
$count2 = $model2->count();
|
||||
|
||||
$rate = 0;
|
||||
if ($count2 > 0) {
|
||||
$rate = ($count - $count2) / $count2 * 100;
|
||||
$rate = number_format($rate, 2);
|
||||
}
|
||||
$res = [
|
||||
'count' => $count,
|
||||
'count2' => $count2,
|
||||
'rate' => $rate,
|
||||
];
|
||||
return $this->json($res, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class User extends BaseModel implements
|
||||
['value' => 'role', 'type' => 'a', 'url' => 'user/role/index', 'name' => '角色'],
|
||||
['value' => 'department', 'type' => 'a', 'url' => 'user/department/index', 'name' => '部门'],
|
||||
['value' => 'group', 'type' => 'a', 'url' => 'user/group/index', 'name' => '用户组'],
|
||||
['value' => 'position', 'type' => 'a', 'url' => 'user/position/index', 'name' => '职位'],
|
||||
['value' => 'position', 'type' => 'a', 'url' => 'user/position/index', 'name' => '岗位'],
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class UserPosition extends BaseModel
|
||||
{
|
||||
protected $table = 'user_position';
|
||||
protected $table = 'user_post';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
|
||||
@@ -59,15 +59,12 @@ class UserAssetService
|
||||
$assets = static::getAssets();
|
||||
}
|
||||
|
||||
$res = [];
|
||||
if ($roleId > 0) {
|
||||
foreach ($assets as $key => $asset) {
|
||||
$rules = (array)json_decode($asset['rules'], true);
|
||||
|
||||
foreach ($rules as $key => $rule) {
|
||||
if (isset($rule[$roleId])) {
|
||||
$res[$asset['name']][$key] = ($rule[$roleId] > 0 ? $rule[$roleId] : 1);
|
||||
}
|
||||
foreach ($assets as $key => $asset) {
|
||||
$rules = (array)json_decode($asset['rules'], true);
|
||||
|
||||
foreach ($rules as $key => $rule) {
|
||||
if (isset($rule[$roleId])) {
|
||||
$res[$asset['name']][$key] = ($rule[$roleId] > 0 ? $rule[$roleId] : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ class UserService
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function getUser($user_id = 0) {
|
||||
public static function getUser($user_id = 0)
|
||||
{
|
||||
$user = null;
|
||||
if ($user_id == 0) {
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -20,7 +20,7 @@ return [
|
||||
'url' => 'user/role/dialog',
|
||||
],
|
||||
'position' => [
|
||||
'name' => '职位',
|
||||
'name' => '岗位',
|
||||
'model' => 'Gdoo\User\Models\UserPosition::Dialog',
|
||||
'url' => 'user/position/dialog',
|
||||
],
|
||||
@@ -30,6 +30,15 @@ return [
|
||||
'url' => 'user/user/dialog',
|
||||
],
|
||||
],
|
||||
'widgets' => [
|
||||
'info_user_count' => [
|
||||
'name' => '用户',
|
||||
'type' => 2,
|
||||
'url' => 'user/widget/userCount',
|
||||
'more_url' => 'user/user/index',
|
||||
'params' => ['permission' => 'dept2', 'date' => 'month'],
|
||||
],
|
||||
],
|
||||
"controllers" => [
|
||||
"user" => [
|
||||
"name" => "用户",
|
||||
|
||||
@@ -185,7 +185,7 @@ body {
|
||||
-->
|
||||
|
||||
<div class="footer">
|
||||
<small class="text-muted">© {{date('Y')}} {{$edition}} {{$version}}</small>
|
||||
<small class="text-muted">© {{date('Y')}} {{$version}}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -56,7 +56,7 @@ body {
|
||||
<div class="line line-dashed"></div>
|
||||
|
||||
<div class="text-center">
|
||||
<small class="text-muted">© {{date('Y')}} {{$edition}} {{$version}}</small>
|
||||
<small class="text-muted">© {{date('Y')}} {{$version}}</small>
|
||||
</div>
|
||||
|
||||
<div class="line line-dashed"></div>
|
||||
|
||||
@@ -47,7 +47,7 @@ body {
|
||||
<div class="line line-dashed"></div>
|
||||
|
||||
<div class="text-center">
|
||||
<small class="text-muted">© {{date('Y')}} {{$edition}} {{$version}}</small>
|
||||
<small class="text-muted">© {{date('Y')}} {{$version}}</small>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -55,11 +55,7 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">安全密钥</label>
|
||||
<strong>{{$user->auth_secret}}</strong>
|
||||
<span class="qrcodeTotp" style="display:none;">
|
||||
<div id="qrcode_canvas"></div>
|
||||
<div id="qrcode_img"></div>
|
||||
</span>
|
||||
<code>{{$user->auth_secret}}</code>
|
||||
<a href="javascript:;" onclick="qrcodeTotp();">
|
||||
<i class="fa fa-qrcode"></i>
|
||||
</a>
|
||||
@@ -82,27 +78,18 @@
|
||||
<script type="text/javascript" src="{{$asset_url}}/vendor/jquery.qrcode.min.js"></script>
|
||||
<script>
|
||||
function qrcodeTotp() {
|
||||
$.messager.alert("二次验证二维码", '<div align="center">' + $("#qrcode_img").prop("outerHTML") + '</div>');
|
||||
}
|
||||
|
||||
function qrcodeMake(qrcode_canvas, qrcode_image) {
|
||||
$("#" + qrcode_canvas).qrcode({
|
||||
$.messager.alert("二次验证二维码", '<div align="center" id="secret-qrcode"></div>');
|
||||
$("#secret-qrcode").qrcode({
|
||||
render: "canvas",
|
||||
text: "{{$secretURL}}",
|
||||
correctLevel: 1,
|
||||
width: 220,
|
||||
height: 220
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
var canvas = $('#' + qrcode_canvas).find('canvas')[0];
|
||||
var image = new Image();
|
||||
image.src = canvas.toDataURL("image/png");
|
||||
$('#' + qrcode_image).append(image);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
// 生成二维码
|
||||
qrcodeMake('qrcode_canvas', 'qrcode_img');
|
||||
// 主题修改
|
||||
$('#change-theme').on('change', function() {
|
||||
var e = $(this).val();
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var action = '{{$form["action"]}}';
|
||||
var table = '{{$form["table"]}}';
|
||||
|
||||
function getAuthSecret(userId) {
|
||||
$.messager.confirm('操作警告', '确定要更新安全密钥。', function(btn) {
|
||||
if (btn == true) {
|
||||
@@ -24,13 +21,27 @@ function getAuthSecret(userId) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
function showSecretQrcode() {
|
||||
$.messager.alert('二次验证二维码','<div align="center" id="secret-qrcode"></div>');
|
||||
$('#secret-qrcode').qrcode({
|
||||
render: "canvas",
|
||||
text: "{{$secret_qrcode}}",
|
||||
width: 200,
|
||||
height: 200
|
||||
});
|
||||
}
|
||||
(function($) {
|
||||
var table = '{{$form["table"]}}';
|
||||
var action = '{{$form["action"]}}';
|
||||
if (action == 'show') {
|
||||
var text = $('#user_auth_secret').text();
|
||||
if (text) {
|
||||
$('#user_auth_secret').html('<a href="javascript:;" id="secretQrcode" onclick="showSecretQrcode();"><code id="secret">'+ text +'</code> <i class="fa fa-qrcode"></i></a>');
|
||||
}
|
||||
} else {
|
||||
var text = $('#user_auth_secret').data('content');
|
||||
$('#user_auth_secret').html('<input type="hidden" id="user_auth_secret_value" name="user[auth_secret]" value="'+ text +'"><code id="secret">' + text + '</code> <a class="btn btn-info btn-xs" onclick="getAuthSecret();" href="javascript:;">更新</a>');
|
||||
}
|
||||
$('#user_auth_secret').html('<input type="hidden" id="user_auth_secret_value" name="user[auth_secret]" value="'+ text +'"><code id="secret">' + text + '</code><a class="btn btn-info btn-xs" onclick="getAuthSecret();" href="javascript:;">更新</a>');
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
Reference in New Issue
Block a user