|
|
|
@ -22,7 +22,6 @@ import (
|
|
|
|
|
"errors"
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
|
|
|
)
|
|
|
|
@ -35,15 +34,14 @@ var (
|
|
|
|
|
|
|
|
|
|
func HandleGoogleCallback(w http.ResponseWriter, r *http.Request) (string, error) {
|
|
|
|
|
code := r.URL.Query().Get("code")
|
|
|
|
|
gameUrl := os.Getenv("GAME_URL")
|
|
|
|
|
if code == "" {
|
|
|
|
|
defer http.Redirect(w, r, gameUrl, http.StatusSeeOther)
|
|
|
|
|
defer 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)
|
|
|
|
|
defer http.Redirect(w, r, GameURL, http.StatusSeeOther)
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|