feat: better getPlayer middleware setup

This commit is contained in:
Deluan
2020-03-12 10:00:37 -04:00
committed by Deluan Quintão
parent 8ec78900c5
commit da36941252
2 changed files with 36 additions and 34 deletions
+3 -3
View File
@@ -106,11 +106,11 @@ func getPlayer(players engine.Players) func(next http.Handler) http.Handler {
player, err := players.Register(ctx, playerId, client, r.Header.Get("user-agent"), ip)
if err != nil {
log.Error("Could not register player", "userName", userName, "client", client)
} else {
ctx = context.WithValue(ctx, "player", *player)
r = r.WithContext(ctx)
}
ctx = context.WithValue(ctx, "player", *player)
r = r.WithContext(ctx)
cookie := &http.Cookie{
Name: playerIDCookieName(userName),
Value: player.ID,