fixed dereferencing of FetchedRedirectURI
This commit is contained in:
@@ -65,7 +65,7 @@ func init() {
|
||||
},
|
||||
Endpoint: google.Endpoint,
|
||||
}
|
||||
|
||||
log.Print("Redirect URL set to: ", googleOauthConfig.RedirectURL)
|
||||
if googleOauthConfig.ClientID == "" {
|
||||
log.Fatal("GOOGLE_CLIENT_ID is not set in environment variables")
|
||||
}
|
||||
@@ -325,8 +325,8 @@ func GoogleCallback(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
helper.LogInfo("Copy this access token: " + accessToken)
|
||||
|
||||
RedirectURI := *FetchedRedirectURI
|
||||
if RedirectURI != "" {
|
||||
if FetchedRedirectURI != nil && *FetchedRedirectURI != "" {
|
||||
RedirectURI := *FetchedRedirectURI
|
||||
log.Print("RedirectURI from query param: ", RedirectURI)
|
||||
if !IsAllowedRedirectURI(RedirectURI) {
|
||||
helper.RespondWithError(w, http.StatusUnauthorized, "Unauthorized RedirectURI")
|
||||
@@ -360,6 +360,7 @@ func validateState(w http.ResponseWriter, r *http.Request) bool {
|
||||
|
||||
func FetchGoogleUserInfo(w http.ResponseWriter, r *http.Request) (models.UserGoogleInfo, error) {
|
||||
code := r.URL.Query().Get("code")
|
||||
log.Print("Authorization code received: ", code)
|
||||
token, err := googleOauthConfig.Exchange(context.Background(), code)
|
||||
if err != nil {
|
||||
helper.LogError(err, "Error exchanging token")
|
||||
|
||||
Reference in New Issue
Block a user