shared-ritm 1.3.65 → 1.3.67
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/dist/shared-ritm.es.js +3239 -3239
- package/dist/shared-ritm.umd.js +133 -133
- package/dist/types/api/settings/ApiService.d.ts +0 -1
- package/package.json +1 -1
- package/src/api/settings/ApiService.ts +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
|
2
2
|
import { Api_Auth_Login } from '@/api/types/Api_Auth'
|
|
3
3
|
|
|
4
|
+
// eslint-disable-next-line
|
|
5
|
+
var isRefreshing = false
|
|
6
|
+
|
|
4
7
|
interface Api_Auth_Refresh {
|
|
5
8
|
accessToken: string
|
|
6
9
|
}
|
|
@@ -11,8 +14,6 @@ export enum ApiServiceType {
|
|
|
11
14
|
|
|
12
15
|
export default class ApiService {
|
|
13
16
|
private axiosInstance: AxiosInstance
|
|
14
|
-
|
|
15
|
-
private isRefreshing = false
|
|
16
17
|
private refreshSubscribers: any[] = []
|
|
17
18
|
|
|
18
19
|
constructor() {
|
|
@@ -54,16 +55,16 @@ export default class ApiService {
|
|
|
54
55
|
|
|
55
56
|
originalRequest._retry = true
|
|
56
57
|
|
|
57
|
-
alert(
|
|
58
|
+
alert(isRefreshing)
|
|
58
59
|
|
|
59
|
-
if (
|
|
60
|
+
if (isRefreshing) {
|
|
60
61
|
alert(originalRequest.url)
|
|
61
62
|
return new Promise(resolve => {
|
|
62
63
|
this.subscribeTokenRefresh(() => resolve(this.axiosInstance(originalRequest)))
|
|
63
64
|
})
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
isRefreshing = true
|
|
67
68
|
|
|
68
69
|
try {
|
|
69
70
|
const response = await this.refresh()
|
|
@@ -76,7 +77,7 @@ export default class ApiService {
|
|
|
76
77
|
|
|
77
78
|
this.setAccessToken(newToken)
|
|
78
79
|
this.onRefreshed()
|
|
79
|
-
|
|
80
|
+
isRefreshing = false
|
|
80
81
|
return this.axiosInstance(originalRequest)
|
|
81
82
|
} catch (e) {
|
|
82
83
|
this.logoutUser()
|
|
@@ -111,7 +112,7 @@ export default class ApiService {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
public logoutUser(): any {
|
|
114
|
-
|
|
115
|
+
isRefreshing = false
|
|
115
116
|
this.post<any, any>(`/v2/logout`, {})
|
|
116
117
|
this.removeToken()
|
|
117
118
|
window.location.href = '/sign-in'
|