Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
f5e46125
Commit
f5e46125
authored
Apr 14, 2019
by
Junling Bu
Browse files
feat[litemall-admin-api]: 管理员不能删除自己账号
parent
d27fd389
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
f5e46125
...
...
@@ -3,7 +3,9 @@ package org.linlinjava.litemall.admin.web;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.subject.Subject
;
import
org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc
;
import
org.linlinjava.litemall.admin.service.LogHelper
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
...
...
@@ -136,6 +138,13 @@ public class AdminAdminController {
return
ResponseUtil
.
badArgument
();
}
// 管理员不能删除自身账号
Subject
currentUser
=
SecurityUtils
.
getSubject
();
LitemallAdmin
currentAdmin
=
(
LitemallAdmin
)
currentUser
.
getPrincipal
();
if
(
currentAdmin
.
getId
().
equals
(
anotherAdminId
))
{
return
ResponseUtil
.
fail
(
ADMIN_DELETE_NOT_ALLOWED
,
"管理员不能删除自己账号"
);
}
adminService
.
deleteById
(
anotherAdminId
);
logHelper
.
logAuthSucceed
(
"删除管理员"
,
admin
.
getUsername
());
return
ResponseUtil
.
ok
();
...
...
Write
Preview
Supports
Markdown
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