check permissions

This commit is contained in:
Settel 2021-08-05 16:36:39 +02:00
parent 55503395a4
commit 00b1925969

View File

@ -7,14 +7,6 @@ import (
)
func (app *Application) SyncHandler(usr *user.User, w http.ResponseWriter, r *http.Request) {
// usrId :=
// usr := app.GetUserById(usrId)
// if usr.Game != gameRef && usr.IsAdmin() {
// w.WriteHeader(http.StatusForbidden)
// fmt.Fprintf(w, "forbidden")
// return
// }
gameRef := r.URL.Query().Get("g")
gm, err := app.GetGameById(gameRef)
if err != nil {
@ -23,6 +15,12 @@ func (app *Application) SyncHandler(usr *user.User, w http.ResponseWriter, r *ht
return
}
if usr.Game != gameRef && !usr.IsAdmin() {
w.WriteHeader(http.StatusForbidden)
fmt.Fprintf(w, "forbidden")
return
}
eng := gm.GetEngine()
eng.SyncHandler(w, r)
}