Skip to content

Commit

Permalink
fix(backend): update url parse logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Oct 16, 2023
1 parent b45493f commit 1d01878
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/internal/handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (h *Handler) HandleAuthenticate(w http.ResponseWriter, r *http.Request) {
h.logError(w, err.Error(), nil, http.StatusBadRequest)
return
}
log.Println(siteURL)
// 1. Extract the user's email from the session or JWT token.
userEmail, err := h.getUserEmailFromToken(r)
if err != nil {
Expand Down Expand Up @@ -227,6 +228,7 @@ func (h *Handler) getUserEmailFromToken(r *http.Request) (string, error) {
}

func (h *Handler) setRedirectCookie(redirectUrl string, r *http.Request, w http.ResponseWriter) error {
log.Println("Host is: " + r.URL.Host)
domain, err := extractMainDomain(r.URL.String())
if err != nil {
log.Println(err.Error())
Expand Down
2 changes: 2 additions & 0 deletions backend/internal/handlers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package handlers
import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"strings"
)

func extractMainDomain(u string) (string, error) {
log.Println("Parsing input: " + u)
// Prepend http:// if no scheme is provided, this ensures url.Parse succeeds
if !strings.Contains(u, "//") {
u = "http://" + u
Expand Down

0 comments on commit 1d01878

Please sign in to comment.