@tapni/auth 0.0.94 → 0.0.95
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/TapniAuth.es.js +187 -187
- package/dist/TapniAuth.umd.js +6 -6
- package/package.json +1 -1
- package/src/App.vue +2 -1
- package/src/mixins/auth.mixin.js +4 -4
- package/src/services/Api.js +2 -2
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -123,8 +123,9 @@ export default {
|
|
|
123
123
|
EventBus.$on('ssoEvent', this.ssoOutgoingEvent)
|
|
124
124
|
EventBus.$on('ssoLogout',(data) => this.logout(data))
|
|
125
125
|
EventBus.$on('getLoggedInAccounts',(data) => this.getLoggedInAccounts(data))
|
|
126
|
-
EventBus.$on('refreshTokenAction',(data) => this.refreshTokenAction(data))
|
|
126
|
+
EventBus.$on('refreshTokenAction',(data) => this.refreshTokenAction({...data, storage: this.$storage}))
|
|
127
127
|
EventBus.$on('switchAccount',(data) => this.switchAccount(data))
|
|
128
|
+
EventBus.$on('setToken',(data) => this.setToken(data))
|
|
128
129
|
},
|
|
129
130
|
methods: {
|
|
130
131
|
async init () {
|
package/src/mixins/auth.mixin.js
CHANGED
|
@@ -245,7 +245,7 @@ export default {
|
|
|
245
245
|
},
|
|
246
246
|
async refreshTokenAction(data) {
|
|
247
247
|
return new Promise(async (resolve, reject) => {
|
|
248
|
-
if (!
|
|
248
|
+
if (!data.refreshToken || this.refreshing) {
|
|
249
249
|
return resolve(null);
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -255,7 +255,7 @@ export default {
|
|
|
255
255
|
id: data.id,
|
|
256
256
|
refreshToken: data.refreshToken,
|
|
257
257
|
refreshTokenAction: true
|
|
258
|
-
},
|
|
258
|
+
}, data.storage)
|
|
259
259
|
);
|
|
260
260
|
if (err && err.response && err.response.data.error === "ACCESS_DENIED") {
|
|
261
261
|
this.logout(false);
|
|
@@ -264,10 +264,10 @@ export default {
|
|
|
264
264
|
|
|
265
265
|
// Set new access token
|
|
266
266
|
if (response && response.data) {
|
|
267
|
-
|
|
267
|
+
EventBus.$emit("setToken", response.data.token);
|
|
268
268
|
EventBus.$emit("ssoEvent", { name: "setStorage", data: this.$storage });
|
|
269
269
|
resolve(response.data.token);
|
|
270
|
-
}
|
|
270
|
+
}
|
|
271
271
|
this.refreshing = false;
|
|
272
272
|
})
|
|
273
273
|
},
|
package/src/services/Api.js
CHANGED
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
setApiRootFromOptions(apiRoot) {
|
|
11
11
|
apiRootFromOptions = apiRoot
|
|
12
12
|
},
|
|
13
|
-
instance(storage, refreshTokenAction =
|
|
13
|
+
instance(storage, refreshTokenAction = null) {
|
|
14
14
|
|
|
15
15
|
const appInfo = version;
|
|
16
16
|
let baseURL = import.meta.env.VITE_APP_API_ROOT + '/v1/';
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
// Check if access token expired
|
|
57
57
|
if (decoded.exp - 30 < Math.floor(Date.now() / 1000)) {
|
|
58
58
|
|
|
59
|
-
return
|
|
59
|
+
return refreshTokenAction({...decoded, refreshToken: storage.refreshTokens ? storage.refreshTokens.split(',')[0] : null, storage })
|
|
60
60
|
.then((token) => {
|
|
61
61
|
config.headers = {
|
|
62
62
|
...config.headers,
|