diff --git a/internal/app/server/auth_handler_v2.go b/internal/app/server/auth_handler_v2.go index c4e7d6b..e31cfaa 100644 --- a/internal/app/server/auth_handler_v2.go +++ b/internal/app/server/auth_handler_v2.go @@ -39,7 +39,6 @@ func (s *Server) GoogleCallbackHandlerV2(ctx *gin.Context) { } } -// BUG: This is not working, not yet sure why func (s *Server) LogoutHandlerV2(ctx *gin.Context) { s.SetCookie(ctx, "jwt_token", "", -1) // s.SetCookie(ctx, "search-filters", "", -1) // TODO: This was copied, might function differently now diff --git a/internal/app/server/cookies.go b/internal/app/server/cookies.go index 0541300..088b346 100644 --- a/internal/app/server/cookies.go +++ b/internal/app/server/cookies.go @@ -20,7 +20,7 @@ func (s *Server) SetCookie(ctx *gin.Context, name, value string, duration time.D path string = "/" httpOnly bool = false // NOTE: Should use false so React can see it! maxAge int - secure bool = false + secure bool = false domain string = "" ) diff --git a/internal/domain/recipe/recipe.go b/internal/domain/recipe/recipe.go index bad14a2..56419fa 100644 --- a/internal/domain/recipe/recipe.go +++ b/internal/domain/recipe/recipe.go @@ -5,9 +5,9 @@ import "time" // RecipeDuration is the duration to prepare recipe. It has JSON tags which allows it to be // marshaled into a JSON object and stored in the database (JSONB). type RecipeDuration struct { - Total int `json:"total"` - Prep int `json:"prep"` - Cook int `json:"cook"` + Total int `json:"Total"` + Prep int `json:"Prep"` + Cook int `json:"Cook"` } // RecipeMeal is the database enum E_MEAL which defines the meal type of a recipe. Postgres enums @@ -49,8 +49,8 @@ func ParseMeal(meal int) RecipeMeal { // RecipeIngredient is a single ingredients in a recipe. These have JSON tags which allow them // to be marshaled into a JSON array and stored in the database (JSONB). type RecipeIngredient struct { - Name string `json:"name"` - Quantity string `json:"quantity"` + Name string `json:"Name"` + Quantity string `json:"Quantity"` } // Recipe is the database model of a recipe. There is no need to map to a different model so diff --git a/internal/domain/server/server.go b/internal/domain/server/server.go index da17824..66093a0 100644 --- a/internal/domain/server/server.go +++ b/internal/domain/server/server.go @@ -38,8 +38,8 @@ type InjectedDependencies struct { // JwtClaims is the data stored in the JSON web token. All that is needed is the users ID and their // Google email provided. type JwtClaims struct { - UserId int `json:"id"` - Email string `json:"email"` + UserId int `json:"Id"` + Email string `json:"Email"` jwt.RegisteredClaims } diff --git a/internal/domain/user/user.go b/internal/domain/user/user.go index ff744a0..0c3b167 100644 --- a/internal/domain/user/user.go +++ b/internal/domain/user/user.go @@ -4,13 +4,13 @@ import "time" // GoogleUserInfo is a data type which contains a mapping of the Google User Info API call. type GoogleUserInfo struct { - Id string `json:"id"` - Email string `json:"email"` - Verified bool `json:"verified_email"` - Name string `json:"name"` - GivenName string `json:"given_name"` - FamilyName string `json:"family_name"` - Picture string `json:"picture"` + Id string `json:"Id"` + Email string `json:"Email"` + Verified bool `json:"VerifiedEmail"` + Name string `json:"Name"` + GivenName string `json:"GivenName"` + FamilyName string `json:"FamilyName"` + Picture string `json:"Picture"` } // User is the database model of a user. There is no need to map to a different model so diff --git a/web/src/main.tsx b/web/src/main.tsx index d6a1d3d..0ec7f69 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -4,6 +4,10 @@ import './index.css' import App from './App.tsx' import { AuthProvider } from './context/AuthProvider.tsx' import { CookiesProvider } from 'react-cookie' +import axios from "axios"; + +// Set the with 'withCredentials' by default +axios.defaults.withCredentials = true; createRoot(document.getElementById('root')!).render( diff --git a/web/src/services/AuthService.ts b/web/src/services/AuthService.ts index d66643f..f8b3cee 100644 --- a/web/src/services/AuthService.ts +++ b/web/src/services/AuthService.ts @@ -3,7 +3,7 @@ import type { GetGoogleAuthUrlResponse, LogoutResponse } from "../types/api/auth import type { ApiError } from "../types/api/error"; -export async function GetGoogleAuthUrl (): Promise { +export async function GetGoogleAuthUrl(): Promise { const response = await axios.get("http://localhost:3000/v2/api/auth/login"); if (response.status !== 200) { @@ -17,7 +17,7 @@ export async function GetGoogleAuthUrl (): Promise { return response.data.url; } -export async function Logout (): Promise { +export async function Logout(): Promise { const response = await axios.get("http://localhost:3000/v2/api/auth/logout"); // This should never happen diff --git a/web/src/services/UserService.ts b/web/src/services/UserService.ts index e33d992..210065b 100644 --- a/web/src/services/UserService.ts +++ b/web/src/services/UserService.ts @@ -5,7 +5,7 @@ import type { GetAuthenticateUserResponse } from "../types/api/user"; export async function GetAuthenticatedUser(): Promise { - const response = await axios.get("http://localhost:3000/v2/api/user", { withCredentials: true }); + const response = await axios.get("http://localhost:3000/v2/api/user"); if (response.data.status !== 200 || response.data.user === undefined){ const err: ApiError = {