Fix bug
This commit is contained in:
parent
983204c0c1
commit
da4192c4a5
@ -101,9 +101,11 @@ public class UserController {
|
|||||||
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE)
|
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE)
|
||||||
public Object deleteUser(@RequestParam String username) {
|
public Object deleteUser(@RequestParam String username) {
|
||||||
List<RoleInfo> roleInfoList = roleService.getRoles(username);
|
List<RoleInfo> roleInfoList = roleService.getRoles(username);
|
||||||
for (RoleInfo roleInfo : roleInfoList) {
|
if (roleInfoList != null) {
|
||||||
if (roleInfo.getRole().equals(NacosRoleServiceImpl.GLOBAL_ADMIN_ROLE)) {
|
for (RoleInfo roleInfo : roleInfoList) {
|
||||||
throw new IllegalArgumentException("cannot delete admin: " + username);
|
if (roleInfo.getRole().equals(NacosRoleServiceImpl.GLOBAL_ADMIN_ROLE)) {
|
||||||
|
throw new IllegalArgumentException("cannot delete admin: " + username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
userDetailsService.deleteUser(username);
|
userDetailsService.deleteUser(username);
|
||||||
|
@ -81,12 +81,15 @@ public class NacosAuthManager implements AuthManager {
|
|||||||
user.setUserName(username);
|
user.setUserName(username);
|
||||||
user.setToken(token);
|
user.setToken(token);
|
||||||
List<RoleInfo> roleInfoList = roleService.getRoles(username);
|
List<RoleInfo> roleInfoList = roleService.getRoles(username);
|
||||||
for (RoleInfo roleInfo : roleInfoList) {
|
if (roleInfoList != null) {
|
||||||
if (roleInfo.getRole().equals(NacosRoleServiceImpl.GLOBAL_ADMIN_ROLE)) {
|
for (RoleInfo roleInfo : roleInfoList) {
|
||||||
user.setGlobalAdmin(true);
|
if (roleInfo.getRole().equals(NacosRoleServiceImpl.GLOBAL_ADMIN_ROLE)) {
|
||||||
break;
|
user.setGlobalAdmin(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,12 +192,11 @@ CREATE TABLE `roles` (
|
|||||||
|
|
||||||
CREATE TABLE `permissions` (
|
CREATE TABLE `permissions` (
|
||||||
`role` varchar(50) NOT NULL,
|
`role` varchar(50) NOT NULL,
|
||||||
`permission` varchar(512) NOT NULL,
|
`resource` varchar(512) NOT NULL,
|
||||||
`gmt_create` bigint NULL,
|
`action` varchar(8) NOT NULL,
|
||||||
`gmt_modified` bigint NULL,
|
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
|
||||||
UNIQUE INDEX `idx_role_resource` (`role` ASC, `permission` ASC) USING BTREE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
||||||
|
|
||||||
INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN');
|
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
|
||||||
|
@ -193,4 +193,4 @@ CREATE TABLE permissions (
|
|||||||
|
|
||||||
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
||||||
|
|
||||||
INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN');
|
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
|
||||||
|
1
pom.xml
1
pom.xml
@ -31,7 +31,6 @@
|
|||||||
<maven>3.2.5</maven>
|
<maven>3.2.5</maven>
|
||||||
</prerequisites>
|
</prerequisites>
|
||||||
|
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<url>git@github.com:alibaba/nacos.git</url>
|
<url>git@github.com:alibaba/nacos.git</url>
|
||||||
<connection>scm:git@github.com:alibaba/nacos.git</connection>
|
<connection>scm:git@github.com:alibaba/nacos.git</connection>
|
||||||
|
Loading…
Reference in New Issue
Block a user