shared-ritm 1.3.52 → 1.3.53

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.
@@ -4,7 +4,6 @@ export declare enum ApiServiceType {
4
4
  }
5
5
  export default class ApiService {
6
6
  private axiosInstance;
7
- private access_token;
8
7
  private isRefreshing;
9
8
  private refreshSubscribers;
10
9
  constructor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.3.52",
3
+ "version": "1.3.53",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -12,14 +12,10 @@ export enum ApiServiceType {
12
12
  export default class ApiService {
13
13
  private axiosInstance: AxiosInstance
14
14
 
15
- private access_token: string | null = null
16
-
17
15
  private isRefreshing = false
18
16
  private refreshSubscribers: any[] = []
19
17
 
20
18
  constructor() {
21
- this.access_token = this.getAccessToken()
22
-
23
19
  this.axiosInstance = axios.create({
24
20
  baseURL: process.env.VUE_APP_BACKEND,
25
21
  headers: {
@@ -31,9 +27,7 @@ export default class ApiService {
31
27
 
32
28
  this.axiosInstance.interceptors.request.use(
33
29
  (config: InternalAxiosRequestConfig) => {
34
- if (this.access_token && config.headers) {
35
- config.headers.Authorization = `Bearer ${this.access_token}`
36
- }
30
+ config.headers.Authorization = `Bearer ${this.getAccessToken()}`
37
31
  return config
38
32
  },
39
33
  (error: AxiosError) => {
@@ -48,7 +42,7 @@ export default class ApiService {
48
42
  async error => {
49
43
  const originalRequest = error.config
50
44
 
51
- if (error.response?.status !== 401) {
45
+ if (error.response?.status !== 401 || originalRequest.url === '/v2/auth/refresh') {
52
46
  return Promise.reject(error)
53
47
  }
54
48
 
@@ -70,21 +64,16 @@ export default class ApiService {
70
64
  const response = await this.refresh()
71
65
 
72
66
  const newToken = response.accessToken
73
- console.log(newToken)
74
67
  if (!newToken) {
75
68
  this.logoutUser()
76
69
  return Promise.reject(error)
77
70
  }
78
71
 
79
72
  this.setAccessToken(newToken)
80
-
81
73
  this.onRefreshed(newToken)
82
74
  this.isRefreshing = false
83
-
84
- originalRequest.headers['Authorization'] = `Bearer ${newToken}`
85
75
  return this.axiosInstance(originalRequest)
86
76
  } catch (e) {
87
- this.isRefreshing = false
88
77
  this.logoutUser()
89
78
  return Promise.reject(e)
90
79
  }
@@ -117,6 +106,7 @@ export default class ApiService {
117
106
  }
118
107
 
119
108
  public logoutUser(): any {
109
+ this.isRefreshing = false
120
110
  this.post<any, any>(`/v2/logout`, {})
121
111
  this.removeToken()
122
112
  window.location.href = '/sign-in'