shared-ritm 1.3.67 → 1.3.68
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 +2770 -2771
- package/dist/shared-ritm.umd.js +119 -119
- package/dist/types/api/settings/ApiService.d.ts +0 -1
- package/package.json +1 -1
- package/src/api/settings/ApiService.ts +5 -8
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import { Api_Auth_Login } from '@/api/types/Api_Auth'
|
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line
|
|
5
5
|
var isRefreshing = false
|
|
6
|
+
// eslint-disable-next-line
|
|
7
|
+
var refreshSubscribers: any[] = []
|
|
6
8
|
|
|
7
9
|
interface Api_Auth_Refresh {
|
|
8
10
|
accessToken: string
|
|
@@ -14,7 +16,6 @@ export enum ApiServiceType {
|
|
|
14
16
|
|
|
15
17
|
export default class ApiService {
|
|
16
18
|
private axiosInstance: AxiosInstance
|
|
17
|
-
private refreshSubscribers: any[] = []
|
|
18
19
|
|
|
19
20
|
constructor() {
|
|
20
21
|
this.axiosInstance = axios.create({
|
|
@@ -49,16 +50,12 @@ export default class ApiService {
|
|
|
49
50
|
originalRequest.url === '/v2/login' ||
|
|
50
51
|
originalRequest._retry
|
|
51
52
|
) {
|
|
52
|
-
alert('sssssss' + originalRequest.url)
|
|
53
53
|
return Promise.reject(error)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
originalRequest._retry = true
|
|
57
57
|
|
|
58
|
-
alert(isRefreshing)
|
|
59
|
-
|
|
60
58
|
if (isRefreshing) {
|
|
61
|
-
alert(originalRequest.url)
|
|
62
59
|
return new Promise(resolve => {
|
|
63
60
|
this.subscribeTokenRefresh(() => resolve(this.axiosInstance(originalRequest)))
|
|
64
61
|
})
|
|
@@ -99,7 +96,7 @@ export default class ApiService {
|
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
private subscribeTokenRefresh(cb: any) {
|
|
102
|
-
|
|
99
|
+
refreshSubscribers.push(cb)
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
private refresh(): Promise<Api_Auth_Refresh> {
|
|
@@ -107,8 +104,8 @@ export default class ApiService {
|
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
private onRefreshed() {
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
refreshSubscribers.forEach(cb => cb())
|
|
108
|
+
refreshSubscribers = []
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
public logoutUser(): any {
|