aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-02 20:48:19 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-02 20:48:19 -0700
commitfd9f5a35cae617c1a18dccbf4c1f0dcd662e9fc4 (patch)
treebbab1c1e3ea9e3b03620ac541ba8aece8a00053a /modern
parentb2dd52831a19cae8d6d46ee1733bde02ad4ca08b (diff)
downloadtrackermap-web-fd9f5a35cae617c1a18dccbf4c1f0dcd662e9fc4.tar.gz
trackermap-web-fd9f5a35cae617c1a18dccbf4c1f0dcd662e9fc4.tar.bz2
trackermap-web-fd9f5a35cae617c1a18dccbf4c1f0dcd662e9fc4.zip
Support token for any path
Diffstat (limited to 'modern')
-rw-r--r--modern/src/Navigation.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/modern/src/Navigation.js b/modern/src/Navigation.js
index d37ca72c..3aa8a12c 100644
--- a/modern/src/Navigation.js
+++ b/modern/src/Navigation.js
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import { Route, Routes, useNavigate } from 'react-router-dom';
+import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { LinearProgress } from '@mui/material';
import MainPage from './main/MainPage';
@@ -52,13 +52,14 @@ const Navigation = () => {
const [redirectsHandled, setRedirectsHandled] = useState(false);
+ const { pathname } = useLocation();
const query = useQuery();
useEffectAsync(async () => {
if (query.get('token')) {
const token = query.get('token');
await fetch(`/api/session?token=${encodeURIComponent(token)}`);
- navigate('/');
+ navigate(pathname);
} else if (query.get('deviceId')) {
const deviceId = query.get('deviceId');
const response = await fetch(`/api/devices?uniqueId=${deviceId}`);