Skip to content

Commit 03b2e76

Browse files
committed
Refactor code structure and remove redundant sections for improved readability and maintainability
1 parent a924291 commit 03b2e76

File tree

25 files changed

+2280
-1327
lines changed

25 files changed

+2280
-1327
lines changed

.github/workflows/deploy-cloudflare-worker.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Create .env file
3838
run: |
3939
echo -n ${{ secrets.AUTH0_AUDIENCE }} | sed -n 's/http.:\/\/\(.*\)/DOMAIN_NAME=\1\n/p' > cloudflare-fake-secured-api/.env
40-
40+
echo "AUTHENTICATION_PROVIDER_TYPE=${{ secrets.AUTHENTICATION_PROVIDER_TYPE }}" >> cloudflare-fake-secured-api/.env
4141
echo "AUTH0_DOMAIN=${{ secrets.AUTH0_DOMAIN }}" >> cloudflare-fake-secured-api/.env
4242
echo "AUTH0_CLIENT_ID=${{ secrets.AUTH0_CLIENT_ID }}" >> cloudflare-fake-secured-api/.env
4343
echo "AUTH0_SCOPE=\"${{ secrets.AUTH0_SCOPE }}\"" >> cloudflare-fake-secured-api/.env
@@ -52,7 +52,7 @@ jobs:
5252
cp wrangler.jsonc wrangler.jsonc.bak
5353
set -a && source .env && set +a
5454
cat .env
55-
cat wrangler.jsonc.bak | sed 's|// "vars".*.|,"vars": { "AUTH0_DOMAIN": "'"${AUTH0_DOMAIN}"'", "AUTH0_CLIENT_ID": "'"${AUTH0_CLIENT_ID}"'", "AUTH0_SCOPE": "'"${AUTH0_SCOPE}"'", "AUTH0_AUDIENCE": "'"${AUTH0_AUDIENCE}"'", "API_BASE_URL": "'"${API_BASE_URL}"'", "CORS_ORIGIN": "'"${CORS_ORIGIN}"'", "READ_PERMISSION": "'"${READ_PERMISSION}"'" }|' > wrangler.jsonc.2
55+
cat wrangler.jsonc.bak | sed 's|// "vars".*.|,"vars": { "AUTHENTICATION_PROVIDER_TYPE": "'"${AUTHENTICATION_PROVIDER_TYPE}"'", "AUTH0_DOMAIN": "'"${AUTH0_DOMAIN}"'", "AUTH0_CLIENT_ID": "'"${AUTH0_CLIENT_ID}"'", "AUTH0_SCOPE": "'"${AUTH0_SCOPE}"'", "AUTH0_AUDIENCE": "'"${AUTH0_AUDIENCE}"'", "API_BASE_URL": "'"${API_BASE_URL}"'", "CORS_ORIGIN": "'"${CORS_ORIGIN}"'", "READ_PERMISSION": "'"${READ_PERMISSION}"'" }|' > wrangler.jsonc.2
5656
cat wrangler.jsonc.2 | sed 's|// "routes".*.|,"routes": [{ "pattern": "'"${DOMAIN_NAME}"'", "custom_domain": true }]|' > wrangler.jsonc
5757
cat wrangler.jsonc
5858
- name: Deploy
@@ -62,6 +62,7 @@ jobs:
6262
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
6363
workingDirectory: cloudflare-fake-secured-api
6464
vars: |
65+
AUTHENTICATION_PROVIDER_TYPE
6566
AUTH0_DOMAIN
6667
AUTH0_CLIENT_ID
6768
AUTH0_SCOPE
@@ -70,6 +71,7 @@ jobs:
7071
CORS_ORIGIN
7172
READ_PERMISSION
7273
env:
74+
AUTHENTICATION_PROVIDER_TYPE: ${{ secrets.AUTHENTICATION_PROVIDER_TYPE }}
7375
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
7476
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
7577
AUTH0_SCOPE: ${{ secrets.AUTH0_SCOPE }}

README.md

Lines changed: 224 additions & 57 deletions
Large diffs are not rendered by default.

client/package-lock.json

Lines changed: 40 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"i18next": "^25.0.2",
4444
"i18next-http-backend": "^3.0.2",
4545
"jose": "^6.0.10",
46+
"oidc-client-ts": "^3.2.1",
4647
"react": "^19.1.0",
4748
"react-dom": "^19.1.0",
4849
"react-i18next": "^15.5.1",
@@ -69,6 +70,7 @@
6970
"eslint-plugin-react": "^7.37.5",
7071
"eslint-plugin-react-hooks": "^5.2.0",
7172
"eslint-plugin-unused-imports": "^4.1.4",
73+
"globals": "^16.1.0",
7274
"postcss": "^8.5.3",
7375
"prettier": "^3.5.3",
7476
"ts-node": "^10.9.2",

client/src/App.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
11
import { Route, Routes } from "react-router-dom";
2-
import { useAuth0 } from "@auth0/auth0-react";
32
import { Suspense } from "react";
43
import { useTranslation } from "react-i18next";
54

65
import { SiteLoading } from "./components/site-loading";
76
import DefaultLayout from "./layouts/default";
87
import { title } from "./components/primitives";
9-
import { AuthenticationGuard, LogoutButton } from "./components/auth0";
8+
import { PageNotFound } from "./pages/404";
9+
import { AuthenticationGuard, LogoutButton, useAuth } from "./authentication";
1010

1111
import IndexPage from "@/pages/index";
1212
import ApiPage from "@/pages/api";
1313
import PricingPage from "@/pages/pricing";
1414
import BlogPage from "@/pages/blog";
1515
import AboutPage from "@/pages/about";
16-
import { PageNotFound } from "./pages/404";
1716

1817
function App() {
19-
const { isLoading, error } = useAuth0();
18+
const { isLoading, isAuthenticated } = useAuth();
2019
const { t } = useTranslation();
2120

2221
if (isLoading) {
2322
return <SiteLoading />;
2423
}
25-
if (error) {
24+
25+
// Gérer les erreurs
26+
if (!isAuthenticated && !isLoading) {
27+
// eslint-disable-next-line no-console
28+
console.log(
29+
"User is not authenticated but auth is not loading - likely an error condition",
30+
);
31+
2632
return (
2733
<DefaultLayout>
2834
<section className="flex flex-col items-center justify-center gap-4 py-8 md:py-10">
2935
<div className="inline-block max-w-lg text-center justify-center">
3036
<div className="mb-4">
3137
<h1 className={title()}>
32-
{t("error")}: {error.message}
38+
{t("error")}: {t("authentication_error")}
3339
</h1>
3440
</div>
3541
<div>

0 commit comments

Comments
 (0)