#21 支持为 user 指定 token

This commit is contained in:
chinyajie
2023-06-30 21:36:48 +08:00
parent ec31eba72f
commit c9b763b9ed
2 changed files with 7 additions and 2 deletions

View File

@@ -378,8 +378,12 @@ func HandleDelUser(c *gin.Context) {
func HandleResetUserToken(c *gin.Context) {
id := to.Int(c.Param("id"))
newtoken := c.Query("token")
if newtoken == "" {
newtoken = uuid.NewString()
}
if err := store.UpdateUser(uint(id), uuid.NewString()); err != nil {
if err := store.UpdateUser(uint(id), newtoken); err != nil {
c.JSON(http.StatusForbidden, gin.H{"error": err.Error()})
return
}