authscape 1.0.14 → 1.0.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.14",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -5,12 +5,12 @@ import cookies from 'next-cookies';
5
5
  import { parseCookies, setCookie, destroyCookie } from 'nookies';
6
6
  import { GetEnvironment } from "./BaseUri";
7
7
 
8
- const setupDefaultOptions = async (ctx = null) => {
8
+ const setupDefaultOptions = async (ctx = {}) => {
9
9
 
10
10
  let defaultOptions = {};
11
11
 
12
- if (ctx == null)
13
- {
12
+ // if (ctx == {})
13
+ // {
14
14
  let accessToken = cookies(ctx).access_token || '';
15
15
 
16
16
  // let accessToken = window.localStorage.getItem("access_token");
@@ -28,14 +28,14 @@ const setupDefaultOptions = async (ctx = null) => {
28
28
  },
29
29
  };
30
30
  }
31
- }
32
- else
33
- {
34
- defaultOptions = {
35
- headers: {
36
- },
37
- };
38
- }
31
+ // }
32
+ // else
33
+ // {
34
+ // defaultOptions = {
35
+ // headers: {
36
+ // },
37
+ // };
38
+ // }
39
39
 
40
40
  return defaultOptions;
41
41
  }
@@ -90,7 +90,7 @@ const RefreshToken = async (originalRequest, instance) => {
90
90
  }
91
91
  }
92
92
 
93
- const apiService = (ctx = null) => {
93
+ const apiService = (ctx = {}) => {
94
94
 
95
95
  let env = GetEnvironment();
96
96
  if (env == "development")
@@ -5,23 +5,29 @@ export default function AuthorizationComponent({children, setCurrentUser, userLo
5
5
 
6
6
  const [loaded, setLoaded] = useState(false);
7
7
 
8
- useEffect(async () => {
8
+
9
+ const validateUserSignedIn = async () => {
10
+
11
+ setLoaded(true);
12
+
13
+ let usr = await apiService().GetCurrentUser();
14
+ if (usr != null)
15
+ {
16
+ setCurrentUser(usr);
17
+ }
18
+ else
19
+ {
20
+ setCurrentUser(null);
21
+ }
22
+
23
+ userLoaded();
24
+ }
25
+
26
+ useEffect(() => {
9
27
 
10
28
  if (!loaded)
11
29
  {
12
- setLoaded(true);
13
-
14
- let usr = await apiService().GetCurrentUser();
15
- if (usr != null)
16
- {
17
- setCurrentUser(usr);
18
- }
19
- else
20
- {
21
- setCurrentUser(null);
22
- }
23
-
24
- userLoaded();
30
+ validateUserSignedIn();
25
31
  }
26
32
 
27
33
  }, [loaded]);