@konfuzio/document-validation-ui 0.1.54-dev.0 → 0.1.55-dev.0

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": "@konfuzio/document-validation-ui",
3
- "version": "0.1.54-dev.0",
3
+ "version": "0.1.55-dev.0",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
package/src/api.js CHANGED
@@ -18,7 +18,9 @@ FILE_REQUEST = axios.create({
18
18
  });
19
19
 
20
20
  const setAuthToken = (token) => {
21
- authToken = token;
21
+ if (token !== authToken) {
22
+ authToken = token;
23
+ }
22
24
  };
23
25
 
24
26
  const setIsKeycloakAuth = (result) => {
@@ -38,17 +40,16 @@ const setLocale = (locale) => {
38
40
  };
39
41
 
40
42
  const getInterceptorConfig = async (config) => {
41
- if (authToken) {
42
- config.headers["Authorization"] = `${
43
- isKeycloakAuth ? "Bearer" : "Token"
44
- } ${authToken}`;
45
- }
46
- config.headers["Accept-Language"] = `${appLocale}-${appLocale}`;
47
-
48
43
  if (isKeycloakAuth) {
49
44
  await updateKeycloakToken();
50
45
  }
51
46
 
47
+ if (authToken) {
48
+ config.headers["Authorization"] = `${isKeycloakAuth ? "Bearer" : "Token"
49
+ } ${authToken}`;
50
+ }
51
+ config.headers["Accept-Language"] = `${appLocale}-${appLocale}`;
52
+
52
53
  return config;
53
54
  };
54
55
 
@@ -29,7 +29,8 @@ export const initKeycloak = async (url, realm, clientId) => {
29
29
  export const updateKeycloakToken = () => {
30
30
  return new Promise(async (resolve, reject) => {
31
31
  if (keycloak) {
32
- const update = await keycloak.updateToken(30);
32
+ await keycloak.updateToken(30);
33
+ API.setAuthToken(keycloak.token);
33
34
  resolve();
34
35
  } else {
35
36
  reject();