Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
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
hj
openApi
Commits
286a94d0
Commit
286a94d0
authored
Apr 14, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后端:修复bug
parent
2e4eac7a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
6 deletions
+17
-6
server/app/Http/Controllers/Middleware/Authenticate.php
server/app/Http/Controllers/Middleware/Authenticate.php
+9
-3
server/app/Repositories/Criteria/UserCriteria.php
server/app/Repositories/Criteria/UserCriteria.php
+6
-2
server/app/Services/AuthService.php
server/app/Services/AuthService.php
+1
-0
server/app/Services/MenusService.php
server/app/Services/MenusService.php
+1
-1
No files found.
server/app/Http/Controllers/Middleware/Authenticate.php
View file @
286a94d0
...
...
@@ -35,7 +35,8 @@ class Authenticate
protected
$whiteList
=
[
'/adminapi/user/info'
,
'/adminapi/auth/logout'
,
'/adminapi/permission/dictData/defaultButtonPermission'
'/adminapi/permission/dictData/defaultButtonPermission'
,
'/adminapi/permission/menu/userRoleMenuList'
];
/**
...
...
@@ -60,7 +61,6 @@ class Authenticate
*/
public
function
handle
(
$request
,
Closure
$next
,
$guard
=
null
)
{
/**
* 如果路由是登出或者是修改密码的时候,需要对token进行处理,否则jwt处理时会出错
*/
...
...
@@ -106,11 +106,17 @@ class Authenticate
$userPermissions
=
[];
$routeParams
=
$request
->
route
()[
1
];
// 如果该路由不存在权限,或者在白名单中,直接不做权限验证
if
(
!
isset
(
$routeParams
[
'permission'
])
||
in_array
(
$routeParams
[
'permission'
],
$this
->
whiteList
)){
if
(
isset
(
$routeParams
[
'permission'
])
&&
in_array
(
$routeParams
[
'permission'
],
$this
->
whiteList
)){
return
true
;
}
if
(
in_array
(
$routeParams
[
'uri'
],
$this
->
whiteList
)){
return
true
;
}
// 获取用户的所有角色组对应的权限
$roles
=
$user
->
roles
;
collect
(
$roles
)
->
map
(
function
(
$role
)
use
(
&
$userPermissions
){
...
...
server/app/Repositories/Criteria/UserCriteria.php
View file @
286a94d0
...
...
@@ -18,12 +18,16 @@ class UserCriteria extends Criteria
{
protected
function
condition
(
Builder
$query
)
:
void
{
if
(
$name
=
$this
->
request
->
get
(
'name'
))
{
$query
->
where
(
'name'
,
'='
,
$name
);
if
(
$name
=
$this
->
request
->
get
(
'n
ickn
ame'
))
{
$query
->
where
(
'n
ickn
ame'
,
'='
,
$name
);
}
if
(
$email
=
$this
->
request
->
get
(
'email'
))
{
$query
->
where
(
'email'
,
'like'
,
"%
$email
%"
);
}
if
(
$username
=
$this
->
request
->
get
(
'username'
))
{
$query
->
where
(
'username'
,
'='
,
$username
);
}
}
}
server/app/Services/AuthService.php
View file @
286a94d0
...
...
@@ -98,6 +98,7 @@ class AuthService
}
$this
->
userRepository
->
pushCriteria
(
new
UserCriteria
(
$request
));
$users
=
$this
->
userRepository
->
paginate
(
$params
[
'page_size'
],[
'id'
,
'username'
,
'nickname'
,
'email'
,
'token'
,
'is_admin'
,
'status'
,
'lastlogin'
,
'created_at'
,
'updated_at'
]);
$returnRecord
=
[];
if
(
$users
){
...
...
server/app/Services/MenusService.php
View file @
286a94d0
...
...
@@ -212,7 +212,6 @@ class MenusService
$params
[
'menu_name'
]
=
$params
[
'name'
];
$params
[
'menu_path'
]
=
$params
[
'path'
];
$params
[
'menu_icon'
]
=
$params
[
'icon'
];
// 根据role规则重组 user
$updateMenus
=
[];
...
...
@@ -221,6 +220,7 @@ class MenusService
$updateMenus
[
$key
]
=
$params
[
$key
];
}
});
$updateMenus
[
'menu_icon'
]
=
$params
[
'icon'
];
// 处理action
//app(RoleAndPermissionsService::class)->checkRequestRolesPermissions($request);
...
...
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