切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
7 years ago
提交
0c953105c8df96d2fb3655a2403d4b7bf009cbfc
1 个父辈
4149fce8
新增后台登录验证码功能
优化登录相关配置
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
35 行增加
和
11 行删除
application/admin/controller/Index.php
application/admin/lang/zh-cn/index.php
application/admin/library/Auth.php
application/admin/view/index/login.html
application/config.php
public/assets/js/backend/index.js
application/admin/controller/Index.php
查看文件 @
0c95310
...
...
@@ -2,7 +2,10 @@
namespace
app\admin\controller
;
use
app\admin\model\AdminLog
;
use
app\common\controller\Backend
;
use
think\Config
;
use
think\Hook
;
use
think\Validate
;
/**
...
...
@@ -64,13 +67,18 @@ class Index extends Backend
'password'
=>
$password
,
'__token__'
=>
$token
,
];
$validate
=
new
Validate
(
$rule
);
if
(
Config
::
get
(
'fastadmin.login_captcha'
))
{
$rule
[
'captcha'
]
=
'require|captcha'
;
$data
[
'captcha'
]
=
$this
->
request
->
post
(
'captcha'
);
}
$validate
=
new
Validate
(
$rule
,
[],
[
'username'
=>
__
(
'Username'
),
'password'
=>
__
(
'Password'
),
'captcha'
=>
__
(
'Captcha'
)]);
$result
=
$validate
->
check
(
$data
);
if
(
!
$result
)
{
$this
->
error
(
$validate
->
getError
(),
$url
,
[
'token'
=>
$this
->
request
->
token
()]);
}
\app\admin\model\
AdminLog
::
setTitle
(
__
(
'Login'
));
AdminLog
::
setTitle
(
__
(
'Login'
));
$result
=
$this
->
auth
->
login
(
$username
,
$password
,
$keeplogin
?
86400
:
0
);
if
(
$result
===
true
)
{
...
...
@@ -87,9 +95,9 @@ class Index extends Backend
{
$this
->
redirect
(
$url
);
}
$background
=
cdnurl
(
"/assets/img/loginbg.jpg"
);
$background
=
cdnurl
(
Config
::
get
(
'fastadmin.login_background'
)
);
$this
->
view
->
assign
(
'background'
,
$background
);
\think\
Hook
::
listen
(
"login_init"
,
$this
->
request
);
Hook
::
listen
(
"login_init"
,
$this
->
request
);
return
$this
->
view
->
fetch
();
}
...
...
application/admin/lang/zh-cn/index.php
查看文件 @
0c95310
...
...
@@ -39,4 +39,5 @@ return [
'Docs'
=>
'官方文档'
,
'Forum'
=>
'交流社区'
,
'QQ qun'
=>
'QQ交流群'
,
'Captcha'
=>
'验证码'
,
];
...
...
application/admin/library/Auth.php
查看文件 @
0c95310
...
...
@@ -5,6 +5,7 @@ namespace app\admin\library;
use
app\admin\model\Admin
;
use
fast\Random
;
use
fast\Tree
;
use
think\Config
;
use
think\Cookie
;
use
think\Request
;
use
think\Session
;
...
...
@@ -14,7 +15,6 @@ class Auth extends \fast\Auth
protected
$requestUri
=
''
;
protected
$breadcrumb
=
[];
protected
$loginUnique
=
false
;
//是否同一账号同一时间只能在一个地方登录
protected
$logined
=
false
;
//登录状态
public
function
__construct
()
...
...
@@ -165,7 +165,7 @@ class Auth extends \fast\Auth
return
false
;
}
//判断是否同一时间同一账号只能在一个地方登录
if
(
$this
->
loginUnique
)
if
(
Config
::
get
(
'fastadmin.login_unique'
)
)
{
$my
=
Admin
::
get
(
$admin
->
id
);
if
(
!
$my
||
$my
->
token
!=
$admin
->
token
)
...
...
application/admin/view/index/login.html
查看文件 @
0c95310
...
...
@@ -63,7 +63,7 @@
<div
class=
"login-form"
>
<img
id=
"profile-img"
class=
"profile-img-card"
src=
"__CDN__/assets/img/avatar.png"
/>
<p
id=
"profile-name"
class=
"profile-name-card"
></p>
<form
action=
""
method=
"post"
id=
"login-form"
>
<div
id=
"errtips"
class=
"hide"
></div>
{:token()}
...
...
@@ -76,7 +76,15 @@
<div
class=
"input-group-addon"
><span
class=
"glyphicon glyphicon-lock"
aria-hidden=
"true"
></span></div>
<input
type=
"password"
class=
"form-control"
id=
"pd-form-password"
placeholder=
"{:__('Password')}"
name=
"password"
autocomplete=
"off"
value=
""
data-rule=
"{:__('Password')}:required;password"
/>
</div>
{if $config.fastadmin.login_captcha}
<div
class=
"input-group"
>
<div
class=
"input-group-addon"
><span
class=
"glyphicon glyphicon-option-horizontal"
aria-hidden=
"true"
></span></div>
<input
type=
"text"
name=
"captcha"
class=
"form-control"
placeholder=
"{:__('Captcha')}"
data-rule=
"{:__('Captcha')}:required;length(4)"
/>
<span
class=
"input-group-addon"
style=
"padding:0;border:none;"
>
<img
src=
"{:captcha_src()}"
width=
"100"
height=
"30"
onclick=
"this.src = '{:captcha_src()}?r=' + Math.random();"
/>
</span>
</div>
{/if}
<div
class=
"form-group"
>
<label
class=
"inline"
for=
"keeplogin"
>
<input
type=
"checkbox"
name=
"keeplogin"
id=
"keeplogin"
value=
"1"
/>
...
...
application/config.php
查看文件 @
0c95310
...
...
@@ -244,7 +244,14 @@ return [
],
//FastAdmin配置
'fastadmin'
=>
[
'version'
=>
'1.0.0.20171026_beta'
,
'api_url'
=>
'http://api.fastadmin.net'
,
//登录验证码
'login_captcha'
=>
false
,
//是否同一账号同一时间只能在一个地方登录
'login_unique'
=>
false
,
//登录页默认背景图
'login_background'
=>
"/assets/img/loginbg.jpg"
,
//版本号
'version'
=>
'1.0.0.20171206_beta'
,
'api_url'
=>
'http://api.fastadmin.net'
,
],
];
...
...
public/assets/js/backend/index.js
查看文件 @
0c95310
...
...
@@ -375,7 +375,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
if
(
lastlogin
)
{
lastlogin
=
JSON
.
parse
(
lastlogin
);
$
(
"#profile-img"
).
attr
(
"src"
,
Backend
.
api
.
cdnurl
(
lastlogin
.
avatar
));
$
(
"#p
d-form-user
name"
).
val
(
lastlogin
.
username
);
$
(
"#p
rofile-
name"
).
val
(
lastlogin
.
username
);
}
//让错误提示框居中
...
...
请
注册
或
登录
后发表评论