@tapni/auth 0.0.92 → 0.0.94
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 +72 -74
- package/dist/TapniAuth.umd.js +6 -6
- package/package.json +1 -1
- package/src/mixins/auth.mixin.js +4 -6
- package/src/services/Api.js +3 -3
package/package.json
CHANGED
package/src/mixins/auth.mixin.js
CHANGED
|
@@ -236,7 +236,7 @@ export default {
|
|
|
236
236
|
this.$storage.UserId = this.loggedInAccounts[username].id;
|
|
237
237
|
this.setLoggedInUserId(this.loggedInAccounts[username].id);
|
|
238
238
|
this.setRefreshToken(this.loggedInAccounts[username].refreshToken);
|
|
239
|
-
await this.refreshTokenAction(
|
|
239
|
+
await this.refreshTokenAction(this.loggedInAccounts[username]);
|
|
240
240
|
|
|
241
241
|
EventBus.$emit("ssoEvent", {
|
|
242
242
|
name: "switchAccount",
|
|
@@ -253,8 +253,8 @@ export default {
|
|
|
253
253
|
const [err, response] = await to(
|
|
254
254
|
AuthService.refreshToken({
|
|
255
255
|
id: data.id,
|
|
256
|
-
refreshToken:
|
|
257
|
-
refreshTokenAction:
|
|
256
|
+
refreshToken: data.refreshToken,
|
|
257
|
+
refreshTokenAction: true
|
|
258
258
|
}, this.$storage)
|
|
259
259
|
);
|
|
260
260
|
if (err && err.response && err.response.data.error === "ACCESS_DENIED") {
|
|
@@ -422,9 +422,7 @@ export default {
|
|
|
422
422
|
if (
|
|
423
423
|
this.loggedInAccounts[username].refreshToken === this.refreshToken
|
|
424
424
|
) {
|
|
425
|
-
this.refreshTokenAction({
|
|
426
|
-
id: this.loggedInAccounts[username].id,
|
|
427
|
-
}).then(() => {
|
|
425
|
+
this.refreshTokenAction(this.loggedInAccounts[username]).then(() => {
|
|
428
426
|
this.setLoggedInUserId(this.loggedInAccounts[username].id);
|
|
429
427
|
if (this.$storage) {
|
|
430
428
|
this.$storage.username = username;
|
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 = false) {
|
|
14
14
|
|
|
15
15
|
const appInfo = version;
|
|
16
16
|
let baseURL = import.meta.env.VITE_APP_API_ROOT + '/v1/';
|
|
@@ -50,13 +50,13 @@ export default {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Check refresh token expiration before request is sent
|
|
53
|
-
if (storage && storage.token && refreshTokenAction
|
|
53
|
+
if (storage && storage.token && !refreshTokenAction) {
|
|
54
54
|
const decoded = jwtDecode(storage.token)
|
|
55
55
|
|
|
56
56
|
// Check if access token expired
|
|
57
57
|
if (decoded.exp - 30 < Math.floor(Date.now() / 1000)) {
|
|
58
58
|
|
|
59
|
-
return refreshTokenAction(decoded)
|
|
59
|
+
return AuthMixin.methods.refreshTokenAction({...decoded, refreshToken: storage.refreshTokens ? storage.refreshTokens.split(',')[0] : null })
|
|
60
60
|
.then((token) => {
|
|
61
61
|
config.headers = {
|
|
62
62
|
...config.headers,
|