feat: support account deletion

This commit is contained in:
ckt1031
2023-07-12 15:57:40 +08:00
parent 0ac0214c41
commit 7c7a45a4f5
3 changed files with 88 additions and 6 deletions

View File

@@ -3,12 +3,13 @@ package controller
import (
"encoding/json"
"fmt"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"net/http"
"one-api/common"
"one-api/model"
"strconv"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
)
type LoginRequest struct {
@@ -477,6 +478,16 @@ func DeleteUser(c *gin.Context) {
func DeleteSelf(c *gin.Context) {
id := c.GetInt("id")
user, _ := model.GetUserById(id, false)
if user.Role == common.RoleRootUser {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "无权删除超级管理员",
})
return
}
err := model.DeleteUserById(id)
if err != nil {
c.JSON(http.StatusOK, gin.H{