@visns-studio/visns-components 4.3.6 → 4.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,6 +78,8 @@ const Login = ({ logo, providers, setSystemAuth, setUserProfile }) => {
78
78
  if (e) {
79
79
  e.preventDefault();
80
80
 
81
+ console.info(location.state);
82
+
81
83
  CustomFetch(
82
84
  '/login/authenticate',
83
85
  'POST',
@@ -92,12 +94,8 @@ const Login = ({ logo, providers, setSystemAuth, setUserProfile }) => {
92
94
  if (result.error === '') {
93
95
  setUserProfile(result.user);
94
96
 
95
- if (
96
- result.previous?.state?.referrer &&
97
- result.previous.state.referrer !== ''
98
- ) {
99
- window.location.href =
100
- result.previous.state.referrer;
97
+ if (result.previous && result.previous !== '') {
98
+ window.location.href = result.previous;
101
99
  } else {
102
100
  setSystemAuth(true);
103
101
  }
@@ -19,8 +19,14 @@ import Reset from '../auth/Reset';
19
19
  import Verify from '../auth/Verify';
20
20
 
21
21
  const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
22
+ const location = useLocation();
23
+
22
24
  return loading ? null : !user || !user.id ? (
23
- <Navigate to={redirectPath} replace />
25
+ <Navigate
26
+ to={redirectPath}
27
+ replace
28
+ state={{ previousUrl: location.pathname }}
29
+ />
24
30
  ) : (
25
31
  <Outlet />
26
32
  );
@@ -53,8 +59,12 @@ const GenericAuth = ({
53
59
  } catch (error) {
54
60
  setIsLoading(false);
55
61
  if (['Unauthenticatdata.'].includes(error)) {
62
+ const currentUrl = window.location.pathname;
63
+
64
+ console.info('aaa');
65
+
56
66
  setIsAuthenticated(false);
57
- navigate('/login');
67
+ navigate('/login', { state: { previousUrl: currentUrl } });
58
68
  }
59
69
  }
60
70
  };
package/package.json CHANGED
@@ -57,7 +57,7 @@
57
57
  "react-dom": "^17.0.1"
58
58
  },
59
59
  "name": "@visns-studio/visns-components",
60
- "version": "4.3.6",
60
+ "version": "4.3.7",
61
61
  "description": "Various packages to assist in the development of our Custom Applications.",
62
62
  "main": "index.js",
63
63
  "scripts": {