check permissions
This commit is contained in:
parent
55503395a4
commit
00b1925969
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user