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> <template>
<div> <div>
<pre class="json">{{ userJson }}</pre> <pre class="json">{{ userJson }}</pre>
<pre v-if="gameinfoJson" class="json">{{ gameinfoJson }}</pre>
<pre class="json">{{ engineJson }}</pre> <pre class="json">{{ engineJson }}</pre>
</div> </div>
</template> </template>
@ -15,9 +14,6 @@ export default {
userJson() { userJson() {
return JSON.stringify(this.$store.state.engine.user, null, 2) return JSON.stringify(this.$store.state.engine.user, null, 2)
}, },
gameinfoJson() {
return JSON.stringify(this.$store.state.engine.gameinfo, null, 2)
},
engineJson() { engineJson() {
return JSON.stringify(this.$store.state.engine.json, null, 2) 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) const response = await $axios.get(url)
store.commit('engine/setJson', response.data) 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) { } catch (e) {
const { status, statusText } = e.response const { status, statusText } = e.response
if (status != 200) { if (status != 200) {

View File

@ -2,7 +2,6 @@ export const state = () => ({
json: {}, json: {},
version: -1, version: -1,
user: undefined, user: undefined,
gameinfo: undefined,
}) })
export const mutations = { export const mutations = {
@ -16,7 +15,4 @@ export const mutations = {
setUser(state, user) { setUser(state, user) {
state.user = 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/login", mux.Login)
mux.PublicHandleFunc("/api/logout", mux.Logout) mux.PublicHandleFunc("/api/logout", mux.Logout)
mux.PrivateHandleFunc("/api/userinfo", mux.GetUserInfo) mux.PrivateHandleFunc("/api/userinfo", mux.GetUserInfo)
mux.PrivateHandleFunc("/api/gameinfo", mux.GetGameInfo)
mux.PrivateHandleFunc("/api/sync", app.SyncHandler) mux.PrivateHandleFunc("/api/sync", app.SyncHandler)
// default handler // default handler