Compare commits

...

15 Commits

Author SHA1 Message Date
4236e44df4 Merge pull request 'fix: reset the filters when the "search all" is hit' (#97) from fix/filter-clear into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 2m44s
Reviewed-on: #97
2026-03-23 22:19:37 -07:00
Hayden Hargreaves
9c2c7f976f fix: reset the filters when the "search all" is hit 2026-03-23 22:19:03 -07:00
3662ced22b Merge pull request 'fix: fixed domain in UI settings of cookie' (#96) from dev into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 1m2s
Reviewed-on: #96
2026-03-12 20:24:09 -07:00
4645d61d65 Merge branch 'master' into dev 2026-03-12 20:24:05 -07:00
Hayden Hargreaves
cb6ac7610c Merge branch 'dev' of gitea:azpect/Potion into dev 2026-03-12 20:23:42 -07:00
Hayden Hargreaves
57ffa49c5b fix: fixed domain in UI settings of cookie 2026-03-12 20:23:22 -07:00
787fff6bb0 Merge pull request 'dev' (#95) from dev into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 53s
Reviewed-on: #95
2026-03-12 20:18:06 -07:00
34080466bd Merge branch 'master' into dev 2026-03-12 20:17:40 -07:00
Hayden Hargreaves
23d426ad71 Merge branch 'dev' of gitea:azpect/Potion into dev 2026-03-12 20:17:01 -07:00
Hayden Hargreaves
bacb070e6d fix: Using UI to set the cookie instead of server. 2026-03-12 20:16:45 -07:00
acb1ed1fd3 Merge pull request 'Trying to fix cookies.' (#94) from dev into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 3m45s
Reviewed-on: #94
2026-03-12 19:39:03 -07:00
8aa748d7ed Merge branch 'master' into dev 2026-03-12 19:38:56 -07:00
Hayden Hargreaves
3ad2c93448 Merge branch 'dev' of gitea:azpect/Potion into dev 2026-03-12 19:37:28 -07:00
Hayden Hargreaves
efeaccc6e3 fix: trying this on prod 2026-03-12 19:37:15 -07:00
f798ddb74c Merge pull request 'feature/orm' (#92) from feature/orm into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 57s
Reviewed-on: #92
2026-02-07 23:44:42 -07:00
7 changed files with 59 additions and 10 deletions

View File

@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"net/url"
"time"
"github.com/gin-gonic/gin"
)
@ -32,12 +31,13 @@ func (s *Server) GoogleCallbackHandlerV2(ctx *gin.Context) {
domain := s.deps.EnvironmentConfig.FrontendDomain
if jwt, err := s.deps.AuthService.GoogleAuthSuccess(state, code); err != nil {
url := fmt.Sprintf("%s/v2/web/login?error=%s", domain, url.QueryEscape(err.Error()))
ctx.Redirect(http.StatusSeeOther, url)
redirectUrl := fmt.Sprintf("%s/v2/web/login?error=%s", domain, url.QueryEscape(err.Error()))
ctx.Redirect(http.StatusSeeOther, redirectUrl)
} else {
url := fmt.Sprintf("%s/v2/web/home", domain)
s.SetCookie(ctx, "jwt_token", jwt, time.Hour*24*7)
ctx.Redirect(http.StatusSeeOther, url)
// Pass JWT via query param - frontend will set the cookie
// This bypasses cross-origin cookie issues with Cloudflare/proxies
redirectUrl := fmt.Sprintf("%s/v2/web/auth/callback?token=%s", domain, url.QueryEscape(jwt))
ctx.Redirect(http.StatusSeeOther, redirectUrl)
}
}

View File

@ -43,8 +43,8 @@ func (s *Server) SetCookie(ctx *gin.Context, name, value string, duration time.D
value,
maxAge,
path,
".gophernest.net", // or your backend domain / parent
true, // secure
"gophernest.net",
true,
httpOnly,
)
case "dev":

View File

@ -13,6 +13,7 @@ import { use, type ReactNode } from 'react';
import { AuthContext } from './context/AuthContext';
import RecipePage from './pages/Recipe';
import SearchPage from './pages/Search';
import AuthCallback from './pages/AuthCallback';
function ProtectedRoute({ children }: { children: ReactNode }) {
const { isLoggedIn } = use(AuthContext)
@ -37,6 +38,9 @@ function App() {
{/* Login page does not inherit WebLayout */}
<Route path="/v2/web/login" element={<LoginPage />} />
{/* Auth callback - handles token from OAuth redirect */}
<Route path="/v2/web/auth/callback" element={<AuthCallback />} />
<Route path="/v2/web" element={<WebLayout />}>
<Route index element={<Navigate to={ROUTE_CONSTANTS.Home} replace />} />
<Route path="home" element={<Home />} />

View File

@ -4,6 +4,7 @@ import type { SearchFilters } from "../types/search";
interface FilterContextType {
filters: SearchFilters;
setFilters: (filters: SearchFilters) => void;
resetFilters: () => void;
}
export const FilterContext = createContext<FilterContextType>({
@ -16,4 +17,5 @@ export const FilterContext = createContext<FilterContextType>({
Favorites: false,
},
setFilters: () => { return },
resetFilters: () => { return },
});

View File

@ -36,7 +36,7 @@ export function FilterProvider({ children }: { children: ReactNode }) {
}, [filters]);
return (
<FilterContext value={{ filters, setFilters }}>
<FilterContext value={{ filters, setFilters, resetFilters: () => setFilters(DEFAULT_FILTERS) }}>
{children}
</FilterContext>
)

View File

@ -0,0 +1,30 @@
import { useEffect } from "react";
import { useSearchParams, useNavigate } from "react-router-dom";
import { useCookies } from "react-cookie";
export default function AuthCallback() {
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const [, setCookie] = useCookies(["jwt_token"]);
useEffect(() => {
const token = searchParams.get("token");
if (token) {
// Set cookie with 7 day expiration, accessible across all subdomains
setCookie("jwt_token", token, {
path: "/",
domain: "gophernest.net", // shared across all subdomains
maxAge: 60 * 60 * 24 * 7, // 7 days in seconds
secure: true,
sameSite: "lax",
});
void navigate("/v2/web/home", { replace: true });
} else {
// No token provided, redirect to login
void navigate("/v2/web/login", { replace: true });
}
}, [searchParams, setCookie, navigate]);
return null;
}

View File

@ -12,10 +12,13 @@ import { GetRecipeOfTheWeek } from "../services/RecipeService";
import { isApiError, type ApiError } from "../types/api/error";
import { AuthContext } from "../context/AuthContext";
import { GetAuthenticatedUserMadeRecipes, GetAuthenticateUserViewedRecipes } from "../services/UserService";
import { useNavigate } from "react-router-dom";
import { FilterContext } from "../context/FilterContext";
export default function Home() {
// Context
const { isLoggedIn } = use(AuthContext);
const { resetFilters } = use(FilterContext);
// Page state
const [recipeOfTheWeek, setRecipeOfTheWeek] = useState<Recipe | null>(null);
@ -24,6 +27,7 @@ export default function Home() {
const [viewedRecipes, setViewedRecipes] = useState<Recipe[]>([]);
const [error, setError] = useState<string>("");
const navigate = useNavigate();
// Fetch the recipe of the week
useEffect(() => {
@ -55,6 +59,12 @@ export default function Home() {
void fetch();
}, [isLoggedIn]);
const viewAllRecipesHandler = () => {
// Clear filters
resetFilters();
void navigate(ROUTE_CONSTANTS.Search);
}
// BUG: Prob remove
useEffect(() => {
if (error)
@ -90,8 +100,11 @@ export default function Home() {
</div>
<p className="leading-relaxed text-gray-800">
Not sure what you want? {" "}
<a href={ROUTE_CONSTANTS.Search} className="text-blue-500 underline hover:text-blue-700 duration-300">
<button onClick={viewAllRecipesHandler} className="text-blue-500 underline hover:text-blue-700 duration-300 cursor-pointer">
View all recipes here
</button>
<a href={ROUTE_CONSTANTS.Search} className="text-blue-500 underline hover:text-blue-700 duration-300">
</a>
</p>
</section>