fix: update release workflow repository and enhance user deletion logic
This commit is contained in:
parent
0552b69b36
commit
45f11483ec
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -146,7 +146,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: robinraju/release-downloader@v1
|
- uses: robinraju/release-downloader@v1
|
||||||
with:
|
with:
|
||||||
repository: hamster1963/nezha-dash-react
|
repository: nezhahq/user-frontend
|
||||||
fileName: dist.zip
|
fileName: dist.zip
|
||||||
latest: true
|
latest: true
|
||||||
extract: true
|
extract: true
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
@ -97,9 +99,14 @@ func createUser(c *gin.Context) (uint64, error) {
|
|||||||
// @Success 200 {object} model.CommonResponse[any]
|
// @Success 200 {object} model.CommonResponse[any]
|
||||||
// @Router /batch-delete/user [post]
|
// @Router /batch-delete/user [post]
|
||||||
func batchDeleteUser(c *gin.Context) (any, error) {
|
func batchDeleteUser(c *gin.Context) (any, error) {
|
||||||
var ids []uint
|
var ids []uint64
|
||||||
if err := c.ShouldBindJSON(&ids); err != nil {
|
if err := c.ShouldBindJSON(&ids); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
auth := c.MustGet(model.CtxKeyAuthorizedUser).(*model.User)
|
||||||
|
if slices.Contains(ids, auth.ID) {
|
||||||
|
return nil, singleton.Localizer.ErrorT("can't delete yourself")
|
||||||
|
}
|
||||||
|
|
||||||
return nil, singleton.DB.Where("id IN (?)", ids).Delete(&model.User{}).Error
|
return nil, singleton.DB.Where("id IN (?)", ids).Delete(&model.User{}).Error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user