@visns-studio/visns-components 4.3.5 → 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,20 +78,24 @@ 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',
84
- auth,
86
+ {
87
+ ...auth,
88
+ location:
89
+ location.state && location.state.previousUrl
90
+ ? location.state.previousUrl
91
+ : '',
92
+ },
85
93
  (result) => {
86
94
  if (result.error === '') {
87
95
  setUserProfile(result.user);
88
96
 
89
- if (
90
- result.previous?.state?.referrer &&
91
- result.previous.state.referrer !== ''
92
- ) {
93
- window.location.href =
94
- result.previous.state.referrer;
97
+ if (result.previous && result.previous !== '') {
98
+ window.location.href = result.previous;
95
99
  } else {
96
100
  setSystemAuth(true);
97
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.5",
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": {