Skip to content

Commit

Permalink
Don't defer redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
patapancakes committed Jul 28, 2024
1 parent 611a0e3 commit ed8122c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/account/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ var (
func HandleDiscordCallback(w http.ResponseWriter, r *http.Request) (string, error) {
code := r.URL.Query().Get("code")
if code == "" {
defer http.Redirect(w, r, GameURL, http.StatusSeeOther)
http.Redirect(w, r, GameURL, http.StatusSeeOther)
return "", errors.New("code is empty")
}

discordId, err := RetrieveDiscordId(code)
if err != nil {
defer http.Redirect(w, r, GameURL, http.StatusSeeOther)
http.Redirect(w, r, GameURL, http.StatusSeeOther)
return "", err
}

Expand Down
4 changes: 2 additions & 2 deletions api/account/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ var (
func HandleGoogleCallback(w http.ResponseWriter, r *http.Request) (string, error) {
code := r.URL.Query().Get("code")
if code == "" {
defer http.Redirect(w, r, GameURL, http.StatusSeeOther)
http.Redirect(w, r, GameURL, http.StatusSeeOther)
return "", errors.New("code is empty")
}

googleId, err := RetrieveGoogleId(code)
if err != nil {
defer http.Redirect(w, r, GameURL, http.StatusSeeOther)
http.Redirect(w, r, GameURL, http.StatusSeeOther)
return "", err
}

Expand Down
2 changes: 1 addition & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func handleProviderCallback(w http.ResponseWriter, r *http.Request) {
})
}

defer http.Redirect(w, r, account.GameURL, http.StatusSeeOther)
http.Redirect(w, r, account.GameURL, http.StatusSeeOther)
}

func handleProviderLogout(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit ed8122c

Please sign in to comment.