From 87dc3c63814fde5e11373cfb2b5664a775bb9db8 Mon Sep 17 00:00:00 2001 From: "youssef.el-mkhantar" Date: Mon, 26 Feb 2024 18:12:34 +0100 Subject: [PATCH 1/6] adding auth routes --- src/pages/home/AuthModal.tsx | 6 +++--- src/pages/login/LoginCallback.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/AuthModal.tsx b/src/pages/home/AuthModal.tsx index ec69159..49bc896 100644 --- a/src/pages/home/AuthModal.tsx +++ b/src/pages/home/AuthModal.tsx @@ -61,7 +61,7 @@ export default function AuthModal(props: AuthModalProps) { const room = generateRoomName(); props.setRoomName(room); if (roomNameConstraintOk(room)) { - api.get('/feedback/whereami').then(res => { + api.get('/authentication/whereami').then(res => { if (res.data.toLowerCase() == 'internet') { if (!props.authenticated) { modal.open(); @@ -82,7 +82,7 @@ export default function AuthModal(props: AuthModalProps) { return navigate('/' + props.roomName); }) .catch(err => { - api.get('/feedback/whereami').then(res => { + api.get('/authentication/whereami').then(res => { if (res.data.toLowerCase() == 'internet') { if (!props.authenticated) { return modal.open(); @@ -118,7 +118,7 @@ export default function AuthModal(props: AuthModalProps) { }, []); const agentConnect = (room: string) => { - fetch(`${import.meta.env.VITE_BASE_URL}/auth/login_authorize?room=${room}`, { + fetch(`${import.meta.env.VITE_BASE_URL}/authentication/login_authorize?room=${room}`, { redirect: 'manual', }).then(res => { if (res.type === 'opaqueredirect') { diff --git a/src/pages/login/LoginCallback.tsx b/src/pages/login/LoginCallback.tsx index 7d2b5c9..5f6a4c5 100644 --- a/src/pages/login/LoginCallback.tsx +++ b/src/pages/login/LoginCallback.tsx @@ -26,7 +26,7 @@ export default function LoginCallback({ } api .get( - `/auth/login_callback?code=${urlParams.get('code')}&state=${urlParams.get( + `/authentication/login_callback?code=${urlParams.get('code')}&state=${urlParams.get( 'state' )}` ) From dac06cad3193686559e9cc4f84afbee83e4f63fc Mon Sep 17 00:00:00 2001 From: "youssef.el-mkhantar" Date: Fri, 1 Mar 2024 14:26:44 +0100 Subject: [PATCH 2/6] logout --- src/App.tsx | 73 ++++++++++++++++------------ src/components/header/Header.tsx | 78 +++++++++++++++++------------- src/pages/login/LogoutCallback.tsx | 2 +- 3 files changed, 87 insertions(+), 66 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 1caea9e..9a9b61d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,13 @@ import Home from './pages/home/Home'; import Layout from './components/layout/Layout'; import { useState, useEffect, ReactNode } from 'react'; -import { Routes, Route, useNavigate, Navigate, useParams } from 'react-router-dom'; +import { + Routes, + Route, + useNavigate, + Navigate, + useParams, +} from 'react-router-dom'; import FAQ from './pages/FAQ/FAQ.md'; import DonneesPerso from './pages/DonneesPerso/DonneesPerso.md'; import Contact from './pages/Contact/Contact.md'; @@ -184,47 +190,44 @@ function App() { const Wrapper = () => { const { roomName } = useParams(); - + if (isAlphanumeric(roomName)) { - return ; - } - // else { + return ( + + ); + } + // else { // return ; // } - return <> + return <>; }; const OtherRoutes = () => { api - .get(`/backend/${window.location.href}`) - .then(res => { - ; - // window.location.href = `/${roomName}`; - return window.location.reload(); - }) - .catch(res => { - ; - // window.location.href = `/error`; - return window.location.reload(); - }) + .get(`/backend/${window.location.href}`) + .then(res => { + ; + // window.location.href = `/${roomName}`; + return window.location.reload(); + }) + .catch(res => { + ; + // window.location.href = `/error`; + return window.location.reload(); + }); - return <> + return <>; }; - + return ( - - } - /> + } /> } /> - } /> + + } + /> } /> } /> } /> diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 1064e48..fdb092a 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -25,40 +25,50 @@ function HeaderComponent({ const [msg, setMsg] = useState(); const logOut = () => { - api - .get('/auth/logout') - .then(res => { - if (res.data.error) { - localStorage.setItem('auth', 'false'); - setAuthenticated(false); - navigate('/'); - } else { - open(res.data, '_self'); - } - }) - .catch(error => { - if (error.response) { - setMsg( - - une erreur est survenue lors de la déconnexion - - ); - } else { - if (error.request) { - setError({ - message: 'une erreur est survenue lors de la déconnexion', - error: { status: '', stack: '' }, - }); - navigate('/error'); - } else { - setError({ - message: 'une erreur est survenue lors de la déconnexion', - error: { status: '', stack: '' }, - }); - navigate('/error'); - } - } - }); + fetch(`${import.meta.env.VITE_BASE_URL}/authentication/logout`, { + redirect: 'manual', + }).then(res => { + if (res.type === 'opaqueredirect') { + window.location.href = res.url; + } else { + // handle normally / pass on to next handler + window.location.href = res.url; + } + }); + // api + // .get('/authentication/logout') + // .then(res => { + // if (res.data.error) { + // localStorage.setItem('auth', 'false'); + // setAuthenticated(false); + // navigate('/'); + // } else { + // open(res.data, '_self'); + // } + // }) + // .catch(error => { + // if (error.response) { + // setMsg( + // + // une erreur est survenue lors de la déconnexion + // + // ); + // } else { + // if (error.request) { + // setError({ + // message: 'une erreur est survenue lors de la déconnexion', + // error: { status: '', stack: '' }, + // }); + // navigate('/error'); + // } else { + // setError({ + // message: 'une erreur est survenue lors de la déconnexion', + // error: { status: '', stack: '' }, + // }); + // navigate('/error'); + // } + // } + // }); }; return (
diff --git a/src/pages/login/LogoutCallback.tsx b/src/pages/login/LogoutCallback.tsx index 7f5a711..b65bde3 100644 --- a/src/pages/login/LogoutCallback.tsx +++ b/src/pages/login/LogoutCallback.tsx @@ -22,7 +22,7 @@ export default function LogoutCallback({ useEffect(() => { api - .get(`/auth/logout_callback?state=${urlParams.get('state')}`) + .get(`/authentication/logout_callback?state=${urlParams.get('state')}`) .then(res => { setAuthenticated(false); localStorage.setItem('auth', 'false'); From 4392781deea5bf8bce46d8c872f924b418cb81bc Mon Sep 17 00:00:00 2001 From: "youssef.el-mkhantar" Date: Thu, 7 Mar 2024 10:41:33 +0100 Subject: [PATCH 3/6] link --- src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9a9b61d..c35d1be 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -53,9 +53,9 @@ function App() { const [participantsNumber, setparticipantsNumber] = useState(0); const [msg, setMsg] = useState(<>); - const sendEmail = (room: string) => { + const sendEmail = (roomName: string) => { api - .post('conference/create/byemail', { conference: room, email: email }) + .post('conference/create/byemail', { roomName, email: email }) .then(res => { if (res.data.error) { setError({ From f586999606664e6a8829180462f3fcdc461e938c Mon Sep 17 00:00:00 2001 From: Hamza KHAIT Date: Tue, 19 Mar 2024 09:17:08 +0100 Subject: [PATCH 4/6] seconde prerelease for testing --- tsconfig.node.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.node.json b/tsconfig.node.json index 9d31e2a..aac0ce5 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -6,4 +6,4 @@ "allowSyntheticDefaultImports": true }, "include": ["vite.config.ts"] -} +} \ No newline at end of file From 3b6966d7f034f4a84aaf2253d2910aaf17e6699f Mon Sep 17 00:00:00 2001 From: Hamza KHAIT Date: Tue, 19 Mar 2024 09:21:55 +0100 Subject: [PATCH 5/6] releasing build for each environment --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e4ed33..01eb630 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: with: node-version: 20 - run: npm ci --force - - run: npm run build + - run: npm run build:$(git branch --show-current) - run: tar -czvf wce-portail.tar.gz -C dist . - run: npx semantic-release env: From dabe55292300c1e6f42f21268c621fbb0d7d0480 Mon Sep 17 00:00:00 2001 From: Hamza KHAIT Date: Tue, 19 Mar 2024 09:24:22 +0100 Subject: [PATCH 6/6] feat: releasing build for each environment --- .github/workflows/release.yml | 2 +- tsconfig.node.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01eb630..ea14524 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,4 +20,4 @@ jobs: - run: tar -czvf wce-portail.tar.gz -C dist . - run: npx semantic-release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/tsconfig.node.json b/tsconfig.node.json index aac0ce5..9d31e2a 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -6,4 +6,4 @@ "allowSyntheticDefaultImports": true }, "include": ["vite.config.ts"] -} \ No newline at end of file +}