removed /api/gameinfo endpoint

This commit is contained in:
Settel 2021-08-09 10:38:01 +02:00
parent b2d86fcb52
commit 257c0975fb
5 changed files with 0 additions and 55 deletions

View File

@ -1,7 +1,6 @@
<template>
<div>
<pre class="json">{{ userJson }}</pre>
<pre v-if="gameinfoJson" class="json">{{ gameinfoJson }}</pre>
<pre class="json">{{ engineJson }}</pre>
</div>
</template>
@ -15,9 +14,6 @@ export default {
userJson() {
return JSON.stringify(this.$store.state.engine.user, null, 2)
},
gameinfoJson() {
return JSON.stringify(this.$store.state.engine.gameinfo, null, 2)
},
engineJson() {
return JSON.stringify(this.$store.state.engine.json, null, 2)
},

View File

@ -25,16 +25,6 @@ export default (context, inject) => {
})
const response = await $axios.get(url)
store.commit('engine/setJson', response.data)
const role = store.state.engine.user?.role
if (role === "gamemaster" || role === "admin") {
const url = buildUrl($config.serverBaseUrl, {
path: '/api/gameinfo',
queryParams: { g: store.state.engine.user?.game },
})
const response = await $axios.get(url)
store.commit('engine/setGameinfo', response.data)
}
} catch (e) {
const { status, statusText } = e.response
if (status != 200) {

View File

@ -2,7 +2,6 @@ export const state = () => ({
json: {},
version: -1,
user: undefined,
gameinfo: undefined,
})
export const mutations = {
@ -16,7 +15,4 @@ export const mutations = {
setUser(state, user) {
state.user = user
},
setGameinfo(state, gameinfo) {
state.gameinfo = gameinfo
}
}

View File

@ -1,36 +0,0 @@
package handler
import (
"encoding/json"
"fmt"
"net/http"
"sirlab.de/go/knyt/user"
)
type gameLight struct {
Players []string `json:"players"`
}
func (authMux *AuthMux) GetGameInfo(usr *user.User, w http.ResponseWriter, r *http.Request) {
gameRef := r.URL.Query().Get("g")
gm, err := authMux.app.GetGameById(gameRef)
if err != nil {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "game not found")
return
}
if !usr.IsGamemaster() || (usr.GetGameId() != gameRef && !usr.IsAdmin()) {
w.WriteHeader(http.StatusForbidden)
fmt.Fprintf(w, "forbidden")
return
}
gmLight := gameLight{
Players: gm.GetActivePlayers(),
}
w.Header().Add("Content-Type", "application/json")
jsonString, _ := json.Marshal(gmLight)
fmt.Fprintf(w, string(jsonString))
}

View File

@ -22,7 +22,6 @@ func main() {
mux.PublicHandleFunc("/api/login", mux.Login)
mux.PublicHandleFunc("/api/logout", mux.Logout)
mux.PrivateHandleFunc("/api/userinfo", mux.GetUserInfo)
mux.PrivateHandleFunc("/api/gameinfo", mux.GetGameInfo)
mux.PrivateHandleFunc("/api/sync", app.SyncHandler)
// default handler