Skip to content
Snippets Groups Projects
Unverified Commit c8b70d13 authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

fix error with trailing slash (#5522)

* fix error with trailing slash

* eslint

* eslint again
parent 0bbd9e28
No related branches found
No related tags found
No related merge requests found
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
// with Greenlight; if not, see <http://www.gnu.org/licenses/>. // with Greenlight; if not, see <http://www.gnu.org/licenses/>.
import React from 'react'; import React from 'react';
import { import { Navigate, Outlet, useMatch } from 'react-router-dom';
Navigate, Outlet, useLocation, useMatch,
} from 'react-router-dom';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import { useAuth } from '../contexts/auth/AuthProvider'; import { useAuth } from '../contexts/auth/AuthProvider';
...@@ -26,7 +24,6 @@ import useDeleteSession from '../hooks/mutations/sessions/useDeleteSession'; ...@@ -26,7 +24,6 @@ import useDeleteSession from '../hooks/mutations/sessions/useDeleteSession';
export default function AuthenticatedOnly() { export default function AuthenticatedOnly() {
const { t } = useTranslation(); const { t } = useTranslation();
const currentUser = useAuth(); const currentUser = useAuth();
const location = useLocation();
const roomsMatch = useMatch('/rooms/:friendlyId'); const roomsMatch = useMatch('/rooms/:friendlyId');
const superAdminMatch = useMatch('/admin/*'); const superAdminMatch = useMatch('/admin/*');
const deleteSession = useDeleteSession({ showToast: false }); const deleteSession = useDeleteSession({ showToast: false });
...@@ -46,7 +43,7 @@ export default function AuthenticatedOnly() { ...@@ -46,7 +43,7 @@ export default function AuthenticatedOnly() {
// Custom logic to redirect from Rooms page to join page if the user isn't signed in // Custom logic to redirect from Rooms page to join page if the user isn't signed in
if (!currentUser.signed_in && roomsMatch) { if (!currentUser.signed_in && roomsMatch) {
return <Navigate to={`${location.pathname}/join`} />; return <Navigate to={`${roomsMatch.pathnameBase}/join`} />;
} }
if (currentUser.signed_in && currentUser.isSuperAdmin && !superAdminMatch) { if (currentUser.signed_in && currentUser.isSuperAdmin && !superAdminMatch) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment