• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 1585790442

12 Dec 2024 12:26PM UTC coverage: 72.806% (-0.008%) from 72.814%
1585790442

push

gitlab-ci

web-flow
Merge pull request #260 from mzedel/men-7842

MEN-7842 - fix(gui): fixed an issue that could lead to unexpected locations in the UI when accessing unauthorized sections while authorized

4240 of 6143 branches covered (69.02%)

Branch coverage included in aggregate %.

6 of 9 new or added lines in 1 file covered. (66.67%)

6 existing lines in 3 files now uncovered.

42684 of 58308 relevant lines covered (73.2%)

21.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.33
/frontend/src/js/config/routes.js
1
// Copyright 2015 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React from 'react';
15
import { Outlet, Route, Routes, useLocation } from 'react-router-dom';
16

17
import AuditLogs from '../components/auditlogs/auditlogs';
18
import Dashboard from '../components/dashboard/dashboard';
19
import Deployments from '../components/deployments/deployments';
20
import Devices from '../components/devices/device-groups';
21
import Help from '../components/help/help';
22
import Login from '../components/login/login';
23
import Password from '../components/login/password';
24
import PasswordReset from '../components/login/passwordreset';
25
import Signup from '../components/login/signup';
26
import Releases from '../components/releases/releases';
27
import Settings from '../components/settings/settings';
28
import { TenantPage } from '../components/tenants/TenantPage';
29

30
const publicRoutes = ['/password', '/signup', '/login'];
2✔
31

32
const LocationValidator = () => {
2✔
33
  const location = useLocation();
17✔
34

35
  if (publicRoutes.some(publicRoute => location.pathname.startsWith(publicRoute))) {
51!
NEW
36
    window.location.replace('/ui/');
×
NEW
37
    return;
×
38
  }
39
  return <Outlet />;
17✔
40
};
41

42
export const PrivateRoutes = () => (
2✔
43
  <Routes>
17✔
44
    <Route element={<LocationValidator />}>
45
      <Route path="auditlog" element={<AuditLogs />} />
46
      <Route path="devices" element={<Devices />}>
47
        <Route path=":status" element={null} />
48
      </Route>
49
      <Route path="releases" element={<Releases />}>
50
        <Route path=":artifactVersion" element={null} />
51
      </Route>
52
      <Route path="deployments" element={<Deployments />}>
53
        <Route path=":tab" element={null} />
54
      </Route>
55
      <Route path="settings" element={<Settings />}>
56
        <Route path=":section" element={null} />
57
      </Route>
58
      <Route path="help" element={<Help />}>
59
        <Route path=":section" element={null} />
60
      </Route>
61
      <Route path="*" element={<Dashboard />} />
62
    </Route>
63
  </Routes>
64
);
65
export const PrivateSPRoutes = () => {
2✔
NEW
66
  return (
×
67
    <Routes>
68
      <Route element={<LocationValidator />}>
69
        <Route path="auditlog" element={<AuditLogs />} />
70
        <Route path="settings" element={<Settings />}>
71
          <Route path=":section" element={null} />
72
        </Route>
73
        <Route path="help" element={<Help />}>
74
          <Route path=":section" element={null} />
75
        </Route>
76
        <Route path="*" element={<TenantPage />} />
77
      </Route>
78
    </Routes>
79
  );
80
};
81

82
export const PublicRoutes = () => (
2✔
83
  <Routes>
6✔
84
    <Route path="password" element={<Password />} />
85
    <Route path="password/:secretHash" element={<PasswordReset />} />
86
    <Route path="signup" element={<Signup />}>
87
      <Route path=":campaign" element={null} />
88
    </Route>
89
    <Route path="*" element={<Login />} />
90
  </Routes>
91
);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc