Skip to content

Commit

Permalink
fix user admin delete bug (DataLinkDC#2685)
Browse files Browse the repository at this point in the history
* Spotless Apply

* fix user admin delete bug

---------

Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Dec 19, 2023
1 parent 88f4c6c commit 0c47171
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.dinky.data.enums.Status;
import org.dinky.data.enums.UserType;
import org.dinky.data.exception.AuthException;
import org.dinky.data.exception.BusException;
import org.dinky.data.model.SysToken;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.data.model.rbac.Menu;
Expand Down Expand Up @@ -152,6 +153,10 @@ public Result<Void> modifyPassword(ModifyPasswordDTO modifyPasswordDTO) {

@Override
public Boolean removeUser(Integer id) {
User user = getById(id);
if (user.getSuperAdminFlag()) {
throw new BusException(Status.USER_SUPERADMIN_CANNOT_DELETE);
}
return baseMapper.deleteById(id) > 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public enum Status {
KICK_OUT(10024, "kick.out"),
TOKEN_FREEZED(10025, "token.freezed"),
NO_PREFIX(10026, "no.prefix"),
USER_SUPERADMIN_CANNOT_DELETE(10027, "user.superadmin.cannot.delete"),

// role
ROLE_ALREADY_EXISTS(10101, "role.already.exists"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ldap.user.duplicat=The ldap matches to multiple user data
git.branch.not.found=Git Branch Not Found
copy.success=Copy Successfully
user.superadmin.cannot.disable=User SuperAdmin Cannot Disable
user.superadmin.cannot.delete=User SuperAdmin Cannot Delete
ds.work.flow.not.save=Please Save Workflow First
schedule.status.unknown=Unknown Status: {0}
user.binding.role.delete.all=User Binding Role Delete All
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ldap.user.duplicat=ldap匹配到多个用户数据
git.branch.not.found=获取不到分支信息
copy.success=复制成功
user.superadmin.cannot.disable=超级管理员用户不能停用
user.superadmin.cannot.delete=超级管理员用户不能删除
ds.work.flow.not.save=请先保存工作流
schedule.status.unknown=未知状态: {0}
user.binding.role.delete.all=用户绑定角色删除所有
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const UserProTable = () => {
</Authorized>,
<Authorized key={`${record.id}_delete_auth`} path='/auth/user/delete'>
<>
{access.isAdmin && !record.isDelete && (
{access.isAdmin && !record.isDelete && !record.superAdminFlag && (
<PopconfirmDeleteBtn
key={`${record.id}_delete`}
onClick={() => handleDeleteUser(record)}
Expand Down

0 comments on commit 0c47171

Please sign in to comment.