fix: prevent guest user from updating profile (#8447)

This commit is contained in:
yoclo 2025-04-29 23:14:16 +08:00 committed by GitHub
parent b2b91a9281
commit 11e7284824
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,6 +113,10 @@ func UpdateCurrent(c *gin.Context) {
return
}
user := c.MustGet("user").(*model.User)
if user.IsGuest() {
common.ErrorStrResp(c, "Guest user can not update profile", 403)
return
}
user.Username = req.Username
if req.Password != "" {
user.SetPassword(req.Password)