feat: /api/userinfo endpoint includes lang

This commit is contained in:
Settel 2022-04-24 19:22:13 +02:00
parent c624f71b7f
commit 952b4d4bcc
3 changed files with 23 additions and 1 deletions

View File

@ -7,6 +7,7 @@
</div>
<div class="page-play__area">
<div v-if="gameState === 'idle'" class="page-play__waiting">
<div class="page-play__teamname">{{ teamname }}</div>
waiting for gamemaster to start game ...
</div>
<ReadySet v-if="gameState === 'ready-set'" :text="gamePhase" />
@ -39,6 +40,9 @@ export default {
const { hash } = this.$route
return hash.indexOf('debug') > -1
},
teamname() {
return this.$store.state.game.name
},
gameState() {
return this.$store.state.game.state
},
@ -93,6 +97,10 @@ export default {
font-size: 24px;
color: #ffffff;
}
&__teamname {
font-size: 36px;
margin-bottom: 36px;
}
&__error-box {
position: absolute;
left: 30%;

View File

@ -100,6 +100,13 @@ func (gm *Game) GetName() string {
return gm.name
}
func (gm *Game) GetLang() string {
gm.mu.Lock()
defer gm.mu.Unlock()
return gm.lang
}
func (gm *Game) GetEngine() *engine.Engine {
gm.mu.Lock()
defer gm.mu.Unlock()

View File

@ -10,17 +10,24 @@ import (
type UserInfoJson struct {
Id string `json:"id"`
Name string `json:"name"`
Lang string `json:"lang"`
Role string `json:"role"`
GameId string `json:"game"`
IsCameo string `json:"isCameo",omitempty`
}
func (authMux *AuthMux) GetUserInfo(usr *user.User, w http.ResponseWriter, r *http.Request) {
gameId := usr.GetGameId()
lang := "de"
if gm, err := authMux.app.GetGameById(gameId); err == nil {
lang = gm.GetLang()
}
usrLight := UserInfoJson{
Id: usr.GetId(),
Name: usr.GetName(),
Role: usr.GetRole(),
GameId: usr.GetGameId(),
Lang: lang,
GameId: gameId,
}
if usr.GetCameo() != nil {
usrLight.IsCameo = "true"