Skip to content

Commit

Permalink
Merge pull request #198 from zond/johnpooch/update-get-phase-to-be-pu…
Browse files Browse the repository at this point in the history
…blic

Update get phase to be public
  • Loading branch information
johnpooch authored Jun 17, 2024
2 parents e4d9155 + 5383d4e commit 4a75c22
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions game/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -1756,11 +1756,6 @@ func devResolvePhaseTimeout(w ResponseWriter, r Request) error {
func loadPhase(w ResponseWriter, r Request) (*Phase, error) {
ctx := appengine.NewContext(r.Req())

user, ok := r.Values()["user"].(*auth.User)
if !ok {
return nil, HTTPErr{"unauthenticated", http.StatusUnauthorized}
}

gameID, err := datastore.DecodeKey(r.Vars()["game_id"])
if err != nil {
return nil, err
Expand All @@ -1785,9 +1780,15 @@ func loadPhase(w ResponseWriter, r Request) (*Phase, error) {
phase.Refresh()
phase.Score(variants.Variants[game.Variant].Nations)

member, isMember := game.GetMemberByUserId(user.Id)
if isMember {
r.Values()[memberNationFlag] = member.Nation
user, ok := r.Values()["user"].(*auth.User)
if !ok {
log.Infof(appengine.NewContext(r.Req()), "Unauthenticated - not setting memberNationFlag")
} else {
log.Infof(appengine.NewContext(r.Req()), "Authenticated - trying to set memberNationFlag")
member, isMember := game.GetMemberByUserId(user.Id)
if isMember {
r.Values()[memberNationFlag] = member.Nation
}
}

return phase, nil
Expand Down

0 comments on commit 4a75c22

Please sign in to comment.