修复登录异常
This commit is contained in:
parent
a018373013
commit
6c12887f8d
@ -6,6 +6,7 @@ use catchAdmin\permissions\OperateLogListener;
|
|||||||
use catchAdmin\permissions\PermissionsMiddleware;
|
use catchAdmin\permissions\PermissionsMiddleware;
|
||||||
use catchAdmin\system\event\LoginLogEvent;
|
use catchAdmin\system\event\LoginLogEvent;
|
||||||
use catchAdmin\system\event\OperateLogEvent;
|
use catchAdmin\system\event\OperateLogEvent;
|
||||||
|
use catchAdmin\user\Auth;
|
||||||
use catcher\command\BackupCommand;
|
use catcher\command\BackupCommand;
|
||||||
use catcher\command\InstallCommand;
|
use catcher\command\InstallCommand;
|
||||||
use catcher\command\MigrateRunCommand;
|
use catcher\command\MigrateRunCommand;
|
||||||
@ -26,12 +27,12 @@ class CatchAdminService extends Service
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->registerCommands();
|
$this->registerCommands();
|
||||||
$this->registerValidates();
|
$this->registerValidates();
|
||||||
$this->registerMiddleWares();
|
$this->registerMiddleWares();
|
||||||
$this->registerEvents();
|
$this->registerEvents();
|
||||||
$this->registerListeners();
|
$this->registerListeners();
|
||||||
|
$this->registerClassAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,4 +117,10 @@ class CatchAdminService extends Service
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function registerClassAlias()
|
||||||
|
{
|
||||||
|
class_alias(Auth::class, 'Auth');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ function deleteButton($name = '删除', $event = 'del')
|
|||||||
function addButton($name = '新增', $event = 'add')
|
function addButton($name = '新增', $event = 'add')
|
||||||
{
|
{
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="%s">%s</a>',
|
'<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="%s">%s</a>',
|
||||||
$event, $name);
|
$event, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\login\controller;
|
namespace catchAdmin\login\controller;
|
||||||
|
|
||||||
|
use app\exceptions\LoginFailedException;
|
||||||
use catchAdmin\user\Auth;
|
use catchAdmin\user\Auth;
|
||||||
use catchAdmin\login\request\LoginRequest;
|
use catchAdmin\login\request\LoginRequest;
|
||||||
use catcher\base\CatchController;
|
use catcher\base\CatchController;
|
||||||
@ -29,7 +30,7 @@ class Index extends CatchController
|
|||||||
* @return bool|string
|
* @return bool|string
|
||||||
* @throws \catcher\exceptions\LoginFailedException
|
* @throws \catcher\exceptions\LoginFailedException
|
||||||
* @throws \cather\exceptions\LoginFailedException
|
* @throws \cather\exceptions\LoginFailedException
|
||||||
* @throws \app\exceptions\LoginFailedException
|
* @throws LoginFailedException
|
||||||
*/
|
*/
|
||||||
public function login(LoginRequest $request)
|
public function login(LoginRequest $request)
|
||||||
{
|
{
|
||||||
@ -37,7 +38,7 @@ class Index extends CatchController
|
|||||||
$isSucceed = Auth::login($params);
|
$isSucceed = Auth::login($params);
|
||||||
// 登录事件
|
// 登录事件
|
||||||
$params['success'] = $isSucceed;
|
$params['success'] = $isSucceed;
|
||||||
event('log', $params);
|
event('loginLog', $params);
|
||||||
|
|
||||||
return $isSucceed ? CatchResponse::success('', '登录成功') :
|
return $isSucceed ? CatchResponse::success('', '登录成功') :
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="login-wrapper">
|
<div class="login-wrapper">
|
||||||
<div class="login-header">
|
<div class="login-header">
|
||||||
<img src="/static/assets/images/logo.png"> EasyWeb后台开发框架
|
<img src="/static/assets/images/logo.png"> CatchAdmin 后台管理系统
|
||||||
</div>
|
</div>
|
||||||
<div class="login-body">
|
<div class="login-body">
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
<table class="layui-table" id="tablePermission" lay-filter="tablePermission"></table>
|
<table class="layui-table" id="tablePermission" lay-filter="tablePermission"></table>
|
||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="tableBarAuth">
|
<script type="text/html" id="tableBarAuth">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
{:editButton()}
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add">新增子菜单</a>
|
{:addButton('新增子菜单')}
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
{:deleteButton()}
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
<table class="layui-table" id="tableRole"></table>
|
<table class="layui-table" id="tableRole"></table>
|
||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="tableBarAuth">
|
<script type="text/html" id="tableBarAuth">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
{:editButton()}
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add">新增子角色</a>
|
{:addButton('新增子角色')}
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
{:deleteButton()}
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\user;
|
namespace catchAdmin\user;
|
||||||
|
|
||||||
|
use catchAdmin\permissions\model\Permissions;
|
||||||
use catchAdmin\user\model\Users;
|
use catchAdmin\user\model\Users;
|
||||||
use catcher\exceptions\FailedException;
|
|
||||||
use catcher\exceptions\LoginFailedException;
|
use catcher\exceptions\LoginFailedException;
|
||||||
use think\facade\Session;
|
use think\facade\Session;
|
||||||
|
|
||||||
@ -15,8 +15,11 @@ class Auth
|
|||||||
*
|
*
|
||||||
* @time 2019年11月28日
|
* @time 2019年11月28日
|
||||||
* @param $params
|
* @param $params
|
||||||
* @throws LoginFailedException
|
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @throws LoginFailedException
|
||||||
*/
|
*/
|
||||||
public static function login($params)
|
public static function login($params)
|
||||||
{
|
{
|
||||||
@ -57,13 +60,40 @@ class Auth
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2019年12月15日
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public static function user()
|
public static function user()
|
||||||
{
|
{
|
||||||
return Session::get(self::getLoginUserKey(), null);
|
return Session::get(self::getLoginUserKey(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2019年12月15日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected static function getLoginUserKey(): string
|
protected static function getLoginUserKey(): string
|
||||||
{
|
{
|
||||||
return md5(self::USER_KEY);
|
return md5(self::USER_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2019年12月15日
|
||||||
|
* @param $mark
|
||||||
|
* @param $module
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasPermissions($mark, $module): bool
|
||||||
|
{
|
||||||
|
$permissionIds = self::user()->get->getPermissionsBy();
|
||||||
|
|
||||||
|
$permissionId = Permissions::where('module', $module)
|
||||||
|
->where('permission_mark', $mark)->value('id');
|
||||||
|
|
||||||
|
return in_array($permissionId, $permissionIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
<table class="layui-table" id="tableUser" lay-filter="tableUser"></table>
|
<table class="layui-table" id="tableUser" lay-filter="tableUser"></table>
|
||||||
<!-- 表格操作列 -->
|
<!-- 表格操作列 -->
|
||||||
<script type="text/html" id="tableBarUser">
|
<script type="text/html" id="tableBarUser">
|
||||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
|
{:editButton()}
|
||||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="{{d.deleted_at ? 'recover' : 'del'}}">{{d.deleted_at ? '恢复' : '删除'}}</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="{{d.deleted_at ? 'recover' : 'del'}}">{{d.deleted_at ? '恢复' : '删除'}}</a>
|
||||||
</script>
|
</script>
|
||||||
<!-- 表格状态列 -->
|
<!-- 表格状态列 -->
|
||||||
|
1
extend/catcher/exceptions/CatchException.php
Normal file
1
extend/catcher/exceptions/CatchException.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?php
|
Loading…
x
Reference in New Issue
Block a user