Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ruer_cms
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蔡闯
ruer_cms
Commits
a9a110a5
Commit
a9a110a5
authored
Jan 06, 2021
by
蔡闯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2020-1
parent
386b460e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
5 deletions
+5
-5
app/admin/controller/AdminUser.php
app/admin/controller/AdminUser.php
+1
-1
app/admin/controller/Index.php
app/admin/controller/Index.php
+1
-2
app/admin/controller/Login.php
app/admin/controller/Login.php
+1
-1
config/cache.php
config/cache.php
+1
-1
public/index.php
public/index.php
+1
-0
No files found.
app/admin/controller/AdminUser.php
View file @
a9a110a5
...
@@ -9,7 +9,7 @@ use think\facade\Request;
...
@@ -9,7 +9,7 @@ use think\facade\Request;
class
AdminUser
extends
Base
class
AdminUser
extends
Base
{
{
//
protected $middleware = ['app\middleware\AdminLoginCheck::class','app\middleware\AdminAfter::class'];
protected
$middleware
=
[
'app\middleware\AdminLoginCheck::class'
,
'app\middleware\AdminAfter::class'
];
//创建权限角色
//创建权限角色
public
function
createRole
()
{
public
function
createRole
()
{
...
...
app/admin/controller/Index.php
View file @
a9a110a5
...
@@ -9,10 +9,9 @@ use think\facade\Request;
...
@@ -9,10 +9,9 @@ use think\facade\Request;
class
Index
extends
Base
{
class
Index
extends
Base
{
//
protected $middleware = ['app\middleware\AdminLoginCheck::class','app\middleware\AdminAfter::class'];
protected
$middleware
=
[
'app\middleware\AdminLoginCheck::class'
,
'app\middleware\AdminAfter::class'
];
public
function
index
()
public
function
index
()
{
{
return
"这是admin下的控制器"
;
return
"这是admin下的控制器"
;
}
}
...
...
app/admin/controller/Login.php
View file @
a9a110a5
...
@@ -44,10 +44,10 @@ class Login extends BaseController
...
@@ -44,10 +44,10 @@ class Login extends BaseController
$userInfo
=
Db
::
name
(
'admin'
)
->
alias
(
"ad"
)
->
join
(
'admin_role'
,
'admin_role.role_id = ad.role_id'
)
->
where
(
$where
)
->
field
(
"ad.type,ad.admin_id,ad.username,admin_role.name,admin_role.url_ids"
)
->
find
();
$userInfo
=
Db
::
name
(
'admin'
)
->
alias
(
"ad"
)
->
join
(
'admin_role'
,
'admin_role.role_id = ad.role_id'
)
->
where
(
$where
)
->
field
(
"ad.type,ad.admin_id,ad.username,admin_role.name,admin_role.url_ids"
)
->
find
();
$data
[
'uid'
]
=
$userInfo
[
'admin_id'
];
$data
[
'uid'
]
=
$userInfo
[
'admin_id'
];
$jwt
=
JWT
::
encode
(
$data
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
$jwt
=
JWT
::
encode
(
$data
,
config
(
'app.jwt_key'
));
//根据参数生成了 token
if
(
$userInfo
){
if
(
$userInfo
){
//把jwt放入set缓存中
//把jwt放入set缓存中
$redis
=
Cache
::
store
(
'redis'
)
->
handler
();
$redis
=
Cache
::
store
(
'redis'
)
->
handler
();
$redis
->
setnx
(
"admin_tokens"
.
"_"
.
$data
[
'uid'
],
$jwt
);
$redis
->
setnx
(
"admin_tokens"
.
"_"
.
$data
[
'uid'
],
$jwt
);
$redis
->
EXPIRE
(
"admin_tokens"
.
"_"
.
$data
[
'uid'
],
3600
);
//设置过期时间,一小时
$redis
->
EXPIRE
(
"admin_tokens"
.
"_"
.
$data
[
'uid'
],
3600
);
//设置过期时间,一小时
...
...
config/cache.php
View file @
a9a110a5
...
@@ -30,7 +30,7 @@ return [
...
@@ -30,7 +30,7 @@ return [
'type'
=>
'redis'
,
'type'
=>
'redis'
,
'host'
=>
env
(
'redis.host'
,
'127.0.0.1'
),
'host'
=>
env
(
'redis.host'
,
'127.0.0.1'
),
'port'
=>
env
(
'redis.port'
,
6379
),
'port'
=>
env
(
'redis.port'
,
6379
),
'password'
=>
env
(
'redis.p
ort
'
,
''
),
'password'
=>
env
(
'redis.p
assword
'
,
''
),
'select'
=>
'0'
,
'select'
=>
'0'
,
// 全局缓存有效期(0为永久有效)
// 全局缓存有效期(0为永久有效)
'expire'
=>
0
,
'expire'
=>
0
,
...
...
public/index.php
View file @
a9a110a5
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
namespace
think
;
namespace
think
;
require
__DIR__
.
'/../vendor/autoload.php'
;
require
__DIR__
.
'/../vendor/autoload.php'
;
header
(
'Access-Control-Allow-Origin: *'
);
header
(
'Access-Control-Allow-Origin: *'
);
// 执行HTTP应用并响应
// 执行HTTP应用并响应
$http
=
(
new
App
())
->
http
;
$http
=
(
new
App
())
->
http
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment