@tapni/auth 0.0.35 → 0.0.37
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 +87 -82
- package/dist/TapniAuth.umd.js +2 -2
- package/package.json +1 -1
- package/src/App.vue +8 -3
- package/src/mixins/auth.mixin.js +4 -7
- package/src/services/Api.js +8 -2
- package/src/services/AuthService.js +4 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -94,7 +94,7 @@ export default {
|
|
|
94
94
|
mixins: [AuthMixin],
|
|
95
95
|
data () {
|
|
96
96
|
return {
|
|
97
|
-
|
|
97
|
+
isSetup: false
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
components: {
|
|
@@ -112,6 +112,11 @@ export default {
|
|
|
112
112
|
default: false
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
|
+
computed: {
|
|
116
|
+
initialized () {
|
|
117
|
+
return this.isSetup || this.isModal;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
115
120
|
async mounted() {
|
|
116
121
|
this.applyBgStyle()
|
|
117
122
|
|
|
@@ -124,8 +129,8 @@ export default {
|
|
|
124
129
|
async init () {
|
|
125
130
|
|
|
126
131
|
// Make sure the function is called just once
|
|
127
|
-
if (this.
|
|
128
|
-
this.
|
|
132
|
+
if (this.isSetup) return;
|
|
133
|
+
this.isSetup = true;
|
|
129
134
|
|
|
130
135
|
this.setToken(this.$storage.token);
|
|
131
136
|
const refreshTokens = this.getRefreshTokens();
|
package/src/mixins/auth.mixin.js
CHANGED
|
@@ -255,7 +255,9 @@ export default {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
// Set new access token
|
|
258
|
-
|
|
258
|
+
if (response && response.data) {
|
|
259
|
+
this.setToken(response.data.token);
|
|
260
|
+
} else console.error('Invalid response setToken');
|
|
259
261
|
},
|
|
260
262
|
async login(data) {
|
|
261
263
|
const [err, response] = await to(AuthService.login(data, this.$storage));
|
|
@@ -327,12 +329,7 @@ export default {
|
|
|
327
329
|
}
|
|
328
330
|
},
|
|
329
331
|
async exchangeAuthCode(data) {
|
|
330
|
-
const [err, response] = await to(
|
|
331
|
-
axios.post(import.meta.env.VITE_APP_API_ROOT + "/v1/users/auth-code", {
|
|
332
|
-
code: data.code,
|
|
333
|
-
code_verifier: data.code_verifier,
|
|
334
|
-
})
|
|
335
|
-
);
|
|
332
|
+
const [err, response] = await to(AuthService.exchangeAuthCode(data, this.storage));
|
|
336
333
|
if (err) return this.errorHandler(err);
|
|
337
334
|
await this.loginSetup(response);
|
|
338
335
|
await this.getLoggedInAccounts();
|
package/src/services/Api.js
CHANGED
|
@@ -4,9 +4,15 @@ import { version } from "../../package.json"
|
|
|
4
4
|
import AuthMixin from "../mixins/auth.mixin"
|
|
5
5
|
|
|
6
6
|
export default (storage, refreshTokenAction = false) => {
|
|
7
|
-
const appInfo = version
|
|
7
|
+
const appInfo = version;
|
|
8
|
+
let baseURL = import.meta.env.VITE_APP_API_ROOT + '/v1/';
|
|
9
|
+
|
|
10
|
+
if (location.hostname.includes('dev.')) {
|
|
11
|
+
baseURL = 'https://api-dev.tapni.co'
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
let apiInstance = axios.create({
|
|
9
|
-
baseURL
|
|
15
|
+
baseURL,
|
|
10
16
|
headers: {
|
|
11
17
|
Authorization: `Bearer ${storage.token}`,
|
|
12
18
|
"X-Client-Name": "sso-" + appInfo.platform,
|