feat(cli): reset init user password

This commit is contained in:
Jacky 2025-03-03 03:40:09 +00:00
parent c56af25671
commit d1d13b620f
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
5 changed files with 113 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package user
import (
"github.com/0xJacky/Nginx-UI/internal/user"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/uozi-tech/cosy"
@ -40,6 +41,12 @@ func InitManageUserRouter(g *gin.RouterGroup) {
}
})
c.BeforeDecodeHook(encryptPassword)
c.ExecutedHook(func(ctx *cosy.Ctx[model.User]) {
if ctx.Payload["password"] != "" {
a := query.AuthToken
_, _ = a.Where(a.UserID.Eq(ctx.ID)).Delete()
}
})
})
c.DestroyHook(func(c *cosy.Ctx[model.User]) {