feat: only admin can specify user in BuyProduct() (#3287)

* fix: balance can be used without login

* fix: balance can be used without login

* fix: fix bug

* fix: fix bug
This commit is contained in:
DacongDA 2024-10-16 00:02:04 +08:00 committed by GitHub
parent dde936e935
commit 7ae067e369
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -182,6 +182,10 @@ func (c *ApiController) BuyProduct() {
paidUserName := c.Input().Get("userName")
owner, _ := util.GetOwnerAndNameFromId(id)
userId := util.GetId(owner, paidUserName)
if paidUserName != "" && !c.IsAdmin() {
c.ResponseError(c.T("general:Only admin user can specify user"))
return
}
if paidUserName == "" {
userId = c.GetSessionUsername()
}