Merging in the React Refactor #56
@ -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) {
|
func (s *Server) LogoutHandlerV2(ctx *gin.Context) {
|
||||||
s.SetCookie(ctx, "jwt_token", "", -1)
|
s.SetCookie(ctx, "jwt_token", "", -1)
|
||||||
// s.SetCookie(ctx, "search-filters", "", -1) // TODO: This was copied, might function differently now
|
// s.SetCookie(ctx, "search-filters", "", -1) // TODO: This was copied, might function differently now
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import "time"
|
|||||||
// RecipeDuration is the duration to prepare recipe. It has JSON tags which allows it to be
|
// 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).
|
// marshaled into a JSON object and stored in the database (JSONB).
|
||||||
type RecipeDuration struct {
|
type RecipeDuration struct {
|
||||||
Total int `json:"total"`
|
Total int `json:"Total"`
|
||||||
Prep int `json:"prep"`
|
Prep int `json:"Prep"`
|
||||||
Cook int `json:"cook"`
|
Cook int `json:"Cook"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecipeMeal is the database enum E_MEAL which defines the meal type of a recipe. Postgres enums
|
// 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
|
// 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).
|
// to be marshaled into a JSON array and stored in the database (JSONB).
|
||||||
type RecipeIngredient struct {
|
type RecipeIngredient struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"Name"`
|
||||||
Quantity string `json:"quantity"`
|
Quantity string `json:"Quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recipe is the database model of a recipe. There is no need to map to a different model so
|
// Recipe is the database model of a recipe. There is no need to map to a different model so
|
||||||
|
|||||||
@ -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
|
// JwtClaims is the data stored in the JSON web token. All that is needed is the users ID and their
|
||||||
// Google email provided.
|
// Google email provided.
|
||||||
type JwtClaims struct {
|
type JwtClaims struct {
|
||||||
UserId int `json:"id"`
|
UserId int `json:"Id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"Email"`
|
||||||
jwt.RegisteredClaims
|
jwt.RegisteredClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,13 +4,13 @@ import "time"
|
|||||||
|
|
||||||
// GoogleUserInfo is a data type which contains a mapping of the Google User Info API call.
|
// GoogleUserInfo is a data type which contains a mapping of the Google User Info API call.
|
||||||
type GoogleUserInfo struct {
|
type GoogleUserInfo struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"Id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"Email"`
|
||||||
Verified bool `json:"verified_email"`
|
Verified bool `json:"VerifiedEmail"`
|
||||||
Name string `json:"name"`
|
Name string `json:"Name"`
|
||||||
GivenName string `json:"given_name"`
|
GivenName string `json:"GivenName"`
|
||||||
FamilyName string `json:"family_name"`
|
FamilyName string `json:"FamilyName"`
|
||||||
Picture string `json:"picture"`
|
Picture string `json:"Picture"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// User is the database model of a user. There is no need to map to a different model so
|
// User is the database model of a user. There is no need to map to a different model so
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import './index.css'
|
|||||||
import App from './App.tsx'
|
import App from './App.tsx'
|
||||||
import { AuthProvider } from './context/AuthProvider.tsx'
|
import { AuthProvider } from './context/AuthProvider.tsx'
|
||||||
import { CookiesProvider } from 'react-cookie'
|
import { CookiesProvider } from 'react-cookie'
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
// Set the with 'withCredentials' by default
|
||||||
|
axios.defaults.withCredentials = true;
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import type { GetAuthenticateUserResponse } from "../types/api/user";
|
|||||||
|
|
||||||
|
|
||||||
export async function GetAuthenticatedUser(): Promise<User | ApiError> {
|
export async function GetAuthenticatedUser(): Promise<User | ApiError> {
|
||||||
const response = await axios.get<GetAuthenticateUserResponse>("http://localhost:3000/v2/api/user", { withCredentials: true });
|
const response = await axios.get<GetAuthenticateUserResponse>("http://localhost:3000/v2/api/user");
|
||||||
|
|
||||||
if (response.data.status !== 200 || response.data.user === undefined){
|
if (response.data.status !== 200 || response.data.user === undefined){
|
||||||
const err: ApiError = {
|
const err: ApiError = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user