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