mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-07 01:03:41 +08:00
Compare commits
2 Commits
v0.1.6-alp
...
v0.1.6-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a5057f02d | ||
|
|
c76027a210 |
@@ -539,9 +539,23 @@ func ManageUser(c *gin.Context) {
|
||||
switch req.Action {
|
||||
case "disable":
|
||||
user.Status = common.UserStatusDisabled
|
||||
if user.Role == common.RoleRootUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "无法禁用超级管理员用户",
|
||||
})
|
||||
return
|
||||
}
|
||||
case "enable":
|
||||
user.Status = common.UserStatusEnabled
|
||||
case "delete":
|
||||
if user.Role == common.RoleRootUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "无法删除超级管理员用户",
|
||||
})
|
||||
return
|
||||
}
|
||||
if err := user.Delete(); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
@@ -557,6 +571,13 @@ func ManageUser(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
if user.Role >= common.RoleAdminUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "该用户已经是管理员",
|
||||
})
|
||||
return
|
||||
}
|
||||
user.Role = common.RoleAdminUser
|
||||
case "demote":
|
||||
if user.Role == common.RoleRootUser {
|
||||
@@ -566,6 +587,13 @@ func ManageUser(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
if user.Role == common.RoleCommonUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "该用户已经是普通用户",
|
||||
})
|
||||
return
|
||||
}
|
||||
user.Role = common.RoleCommonUser
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ const EditToken = () => {
|
||||
disabled={unlimited_times}
|
||||
/>
|
||||
</Form.Field>
|
||||
<Button type={'button'} onClick={() => {
|
||||
<Button type={'button'} style={{marginBottom: '14px'}} onClick={() => {
|
||||
setUnlimitedTimes();
|
||||
}}>{unlimited_times ? '取消无限次' : '设置为无限次'}</Button>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user