Skip to content

Commit

Permalink
fix(porte): content type
Browse files Browse the repository at this point in the history
  • Loading branch information
yyewolf committed Nov 2, 2023
1 parent f274675 commit 5775eec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion nfc/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nfc
nfc
.env
3 changes: 2 additions & 1 deletion porte/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nfc
porte
.env
8 changes: 6 additions & 2 deletions porte/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func routes(e *echo.Echo) {
return c.JSON(400, gin.H{"error": err.Error()})
}

logrus.Debug("POST /auth/card: ", string(data))
rdr := bytes.NewReader(data)

// Http client with X-Local-Token
Expand All @@ -42,6 +43,7 @@ func routes(e *echo.Echo) {
}

request.Header.Add("X-Local-Token", conf.LocalToken)
request.Header.Add("Content-Type", "application/json")

// post the same request to API_URL
r, err := client.Do(request)
Expand All @@ -60,15 +62,17 @@ func routes(e *echo.Echo) {
}

request.Header.Add("X-Local-Token", conf.LocalToken)
for _, cookie := range r.Cookies() {
request.AddCookie(cookie)
}

r2, err := client.Do(request)
if err != nil {
logrus.Debug("/account/admin returned ", r.StatusCode)
return c.JSON(400, gin.H{"error": err.Error()})
}

if r2.StatusCode != http.StatusOK {
logrus.Debug("/account/admin returned ", r.StatusCode)
logrus.Debug("/account/admin returned ", r2.StatusCode)
return c.JSON(400, gin.H{"error": "invalid card"})
}

Expand Down

0 comments on commit 5775eec

Please sign in to comment.