切换导航条
此项目
正在载入...
登录
何书鹏
/
anttest
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
7 years ago
提交
4149fce83840261de1dc4ae4d85b306796efb023
1 个父辈
65d04fe5
master
修复规则添加正则错误的BUG
优化登录状态session中存储为数组格式 优化Auth的isLogin方法只需查询一次数据库
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
42 行增加
和
40 行删除
application/admin/controller/general/Profile.php
application/admin/lang/zh-cn/auth/rule.php
application/admin/library/Auth.php
application/admin/model/AdminLog.php
application/admin/validate/AuthRule.php
application/extra/site.php
extend/fast/Auth.php
application/admin/controller/general/Profile.php
查看文件 @
4149fce
...
...
@@ -2,10 +2,10 @@
namespace
app\admin\controller\general
;
use
think\Session
;
use
app\admin\model\AdminLog
;
use
app\admin\model\Admin
;
use
app\common\controller\Backend
;
use
fast\Random
;
use
think\Session
;
/**
* 个人配置
...
...
@@ -64,14 +64,10 @@ class Profile extends Backend
}
if
(
$params
)
{
model
(
'admin'
)
->
where
(
'id'
,
$this
->
auth
->
id
)
->
update
(
$params
);
$admin
=
Admin
::
get
(
$this
->
auth
->
id
);
$admin
->
save
(
$params
);
//因为个人资料面板读取的Session显示,修改自己资料后同时更新Session
$admin
=
Session
::
get
(
'admin'
);
$admin_id
=
$admin
?
$admin
->
id
:
0
;
if
(
$this
->
auth
->
id
==
$admin_id
){
$admin
=
model
(
'admin'
)
->
get
([
'id'
=>
$admin_id
]);
Session
::
set
(
"admin"
,
$admin
);
}
Session
::
set
(
"admin"
,
$admin
->
toArray
());
$this
->
success
();
}
$this
->
error
();
...
...
application/admin/lang/zh-cn/auth/rule.php
查看文件 @
4149fce
<?php
return
[
'Toggle all'
=>
'显示全部'
,
'Condition'
=>
'规则条件'
,
'Remark'
=>
'备注'
,
'Icon'
=>
'图标'
,
'Alert'
=>
'警告'
,
'Name'
=>
'规则URL'
,
'Controller/Action'
=>
'控制器名/方法名'
,
'Ismenu'
=>
'菜单'
,
'Search icon'
=>
'搜索图标'
,
'The non-menu rule must have parent'
=>
'非菜单规则节点必须有父级'
,
'If not necessary, use the command line to build rule'
=>
'非必要情况下请直接使用命令行php think menu来生成'
,
'Name only supports letters, numbers, underscore and pipe'
=>
'URL规则只能是小写字母、数字、下划线和|组成'
,
'Toggle all'
=>
'显示全部'
,
'Condition'
=>
'规则条件'
,
'Remark'
=>
'备注'
,
'Icon'
=>
'图标'
,
'Alert'
=>
'警告'
,
'Name'
=>
'规则URL'
,
'Controller/Action'
=>
'控制器名/方法名'
,
'Ismenu'
=>
'菜单'
,
'Search icon'
=>
'搜索图标'
,
'The non-menu rule must have parent'
=>
'非菜单规则节点必须有父级'
,
'If not necessary, use the command line to build rule'
=>
'非必要情况下请直接使用命令行php think menu来生成'
,
'Name only supports letters, numbers, underscore and slash'
=>
'URL规则只能是小写字母、数字、下划线和/组成'
,
];
...
...
application/admin/library/Auth.php
查看文件 @
4149fce
...
...
@@ -15,6 +15,7 @@ class Auth extends \fast\Auth
protected
$requestUri
=
''
;
protected
$breadcrumb
=
[];
protected
$loginUnique
=
false
;
//是否同一账号同一时间只能在一个地方登录
protected
$logined
=
false
;
//登录状态
public
function
__construct
()
{
...
...
@@ -89,7 +90,7 @@ class Auth extends \fast\Auth
{
return
false
;
}
Session
::
set
(
"admin"
,
$admin
);
Session
::
set
(
"admin"
,
$admin
->
toArray
()
);
//刷新自动登录的时效
$this
->
keeplogin
(
$keeptime
);
return
true
;
...
...
@@ -154,6 +155,10 @@ class Auth extends \fast\Auth
*/
public
function
isLogin
()
{
if
(
$this
->
logined
)
{
return
true
;
}
$admin
=
Session
::
get
(
'admin'
);
if
(
!
$admin
)
{
...
...
@@ -168,6 +173,7 @@ class Auth extends \fast\Auth
return
false
;
}
}
$this
->
logined
=
true
;
return
true
;
}
...
...
application/admin/model/AdminLog.php
查看文件 @
4149fce
...
...
@@ -2,6 +2,7 @@
namespace
app\admin\model
;
use
app\admin\library\Auth
;
use
think\Model
;
class
AdminLog
extends
Model
...
...
@@ -29,9 +30,9 @@ class AdminLog extends Model
public
static
function
record
(
$title
=
''
)
{
$admin
=
\think\Session
::
get
(
'admin'
);
$admin_id
=
$admin
?
$admin
->
id
:
0
;
$username
=
$admin
?
$admin
->
username
:
__
(
'Unknown'
);
$auth
=
Auth
::
instance
();
$admin_id
=
$auth
->
isLogin
()
?
$auth
->
id
:
0
;
$username
=
$auth
->
isLogin
()
?
$auth
->
username
:
__
(
'Unknown'
);
$content
=
self
::
$content
;
if
(
!
$content
)
{
...
...
@@ -48,7 +49,7 @@ class AdminLog extends Model
if
(
!
$title
)
{
$title
=
[];
$breadcrumb
=
\app\admin\library\
Auth
::
instance
()
->
getBreadcrumb
();
$breadcrumb
=
Auth
::
instance
()
->
getBreadcrumb
();
foreach
(
$breadcrumb
as
$k
=>
$v
)
{
$title
[]
=
$v
[
'title'
];
...
...
application/admin/validate/AuthRule.php
查看文件 @
4149fce
...
...
@@ -10,7 +10,7 @@ class AuthRule extends Validate
/**
* 正则
*/
protected
$regex
=
[
'format'
=>
'[a-z0-9_\
|
]+'
];
protected
$regex
=
[
'format'
=>
'[a-z0-9_\
/
]+'
];
/**
* 验证规则
...
...
@@ -24,7 +24,7 @@ class AuthRule extends Validate
* 提示消息
*/
protected
$message
=
[
'name.format'
=>
'URL规则只能是小写字母、数字、下划线和
|
组成'
'name.format'
=>
'URL规则只能是小写字母、数字、下划线和
/
组成'
];
/**
...
...
@@ -45,7 +45,7 @@ class AuthRule extends Validate
'name'
=>
__
(
'Name'
),
'title'
=>
__
(
'Title'
),
];
$this
->
message
[
'name.format'
]
=
__
(
'Name only supports letters, numbers, underscore and
pipe
'
);
$this
->
message
[
'name.format'
]
=
__
(
'Name only supports letters, numbers, underscore and
slash
'
);
parent
::
__construct
(
$rules
,
$message
,
$field
);
}
...
...
application/extra/site.php
查看文件 @
4149fce
...
...
@@ -2,7 +2,7 @@
return
array
(
'name'
=>
'FastAdmin'
,
'beian'
=>
'
粤ICP备15054802号-4
'
,
'beian'
=>
''
,
'cdnurl'
=>
''
,
'version'
=>
'1.0.1'
,
'timezone'
=>
'Asia/Shanghai'
,
...
...
@@ -15,18 +15,18 @@ return array (
'fixedpage'
=>
'dashboard'
,
'categorytype'
=>
array
(
'default'
=>
'默认'
,
'page'
=>
'单页'
,
'article'
=>
'文章'
,
'test'
=>
'测试'
,
'default'
=>
'Default'
,
'page'
=>
'Page'
,
'article'
=>
'Article'
,
'test'
=>
'Test'
,
),
'configgroup'
=>
array
(
'basic'
=>
'基础配置'
,
'email'
=>
'邮件配置'
,
'dictionary'
=>
'字典配置'
,
'user'
=>
'会员配置'
,
'example'
=>
'示例分组'
,
'basic'
=>
'Basic'
,
'email'
=>
'Email'
,
'dictionary'
=>
'Dictionary'
,
'user'
=>
'User'
,
'example'
=>
'Example'
,
),
'mail_type'
=>
'1'
,
'mail_smtp_host'
=>
'smtp.qq.com'
,
...
...
extend/fast/Auth.php
查看文件 @
4149fce
...
...
@@ -18,7 +18,6 @@ use think\Db;
use
think\Config
;
use
think\Session
;
use
think\Request
;
use
think\Loader
;
/**
* 权限认证类
...
...
请
注册
或
登录
后发表评论