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