@tapni/auth 0.0.109 → 0.0.118
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/.vite/manifest.json +32 -0
- package/dist/Account-5DndxBQe.js +111 -0
- package/dist/QR-rB8KdJig.js +41 -0
- package/dist/TapniAuth.es.js +2 -16733
- package/dist/TapniAuth.umd.js +39 -39
- package/dist/install-QOxCq9FJ.js +18408 -0
- package/dist/style.css +1 -1
- package/dist/web-AImUTDQQ.js +54 -0
- package/package.json +6 -3
- package/src/App.vue +55 -11
- package/src/components/Language.vue +1 -1
- package/src/components/ModalOverlay.vue +1 -0
- package/src/components/OTP.vue +120 -0
- package/src/install.js +0 -3
- package/src/main.js +3 -11
- package/src/mixins/apple.mixin.js +2 -2
- package/src/mixins/auth.mixin.js +52 -509
- package/src/mixins/facebook.mixin.js +2 -2
- package/src/mixins/global.mixin.js +5 -4
- package/src/mixins/google.mixin.js +2 -2
- package/src/mixins/mfa-auth.mixin.js +76 -0
- package/src/mixins/microsoft.mixin.js +3 -7
- package/src/mixins/okta.mixin.js +1 -1
- package/src/mixins/qr-auth.mixin.js +6 -1
- package/src/mixins/saml.mixin.js +2 -1
- package/src/routes.js +13 -0
- package/src/services/Api.js +15 -28
- package/src/services/AuthService.js +42 -37
- package/src/services/CompanyService.js +7 -8
- package/src/services/DeviceService.js +5 -6
- package/src/services/UserService.js +22 -23
- package/src/services/UtilService.js +1 -1
- package/src/store/locales/en.js +8 -1
- package/src/store/store.js +563 -0
- package/src/views/Account.vue +236 -0
- package/src/views/Login.vue +29 -15
- package/src/views/MFA.vue +109 -0
- package/src/views/Register.vue +10 -10
- package/src/views/Reset.vue +3 -3
- package/src/views/Verify.vue +4 -4
- package/src/views/Welcome.vue +3 -2
- package/src/styles/framework.css +0 -4012
- package/src/styles/inter.ttf +0 -0
- package/src/styles/style.css +0 -618
package/src/mixins/auth.mixin.js
CHANGED
|
@@ -1,522 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import UserService from "../services/UserService";
|
|
4
|
-
import DeviceService from "../services/DeviceService";
|
|
5
|
-
import AuthService from "../services/AuthService";
|
|
6
|
-
import CompanyService from "../services/CompanyService";
|
|
7
|
-
|
|
8
|
-
import { EventBus } from "../store/event-bus";
|
|
9
|
-
import { Device } from "@capacitor/device";
|
|
10
|
-
import axios from "axios";
|
|
11
|
-
import en from "../store/locales/en.js";
|
|
12
|
-
import de from "../store/locales/de.js";
|
|
13
|
-
import es from "../store/locales/es.js";
|
|
14
|
-
import fr from "../store/locales/fr.js";
|
|
15
|
-
import it from "../store/locales/it.js";
|
|
16
|
-
import sr from "../store/locales/sr.js";
|
|
17
|
-
import tr from "../store/locales/tr.js";
|
|
18
|
-
import cn from "../store/locales/cn.js";
|
|
19
|
-
import kr from "../store/locales/kr.js";
|
|
1
|
+
import { mapState, mapActions, mapGetters } from 'vuex';
|
|
20
2
|
import GlobalMixin from './global.mixin'
|
|
3
|
+
|
|
21
4
|
export default {
|
|
22
5
|
mixins: [GlobalMixin],
|
|
23
|
-
data() {
|
|
24
|
-
return {
|
|
25
|
-
lang: "en",
|
|
26
|
-
token: "",
|
|
27
|
-
refreshToken: "",
|
|
28
|
-
refreshing: "",
|
|
29
|
-
loggedInUserId: "",
|
|
30
|
-
ssoUser: {},
|
|
31
|
-
ssoCompany: {},
|
|
32
|
-
device: {},
|
|
33
|
-
loggedInAccounts: {},
|
|
34
|
-
ssoLang: {
|
|
35
|
-
en: en.state,
|
|
36
|
-
de: de.state,
|
|
37
|
-
es: es.state,
|
|
38
|
-
fr: fr.state,
|
|
39
|
-
it: it.state,
|
|
40
|
-
sr: sr.state,
|
|
41
|
-
tr: tr.state,
|
|
42
|
-
cn: cn.state,
|
|
43
|
-
kr: kr.state,
|
|
44
|
-
},
|
|
45
|
-
display: import.meta.env.VITE_APP_MODE,
|
|
46
|
-
redirect_uri: import.meta.env.VITE_APP_APP_ROOT + "/callback/auth",
|
|
47
|
-
response_type: "token",
|
|
48
|
-
state: "",
|
|
49
|
-
allowedOrigins: [
|
|
50
|
-
"https://business.tapni.com",
|
|
51
|
-
"https://business-dev.tapni.com",
|
|
52
|
-
"https://tapni.com",
|
|
53
|
-
"https://tapni.co",
|
|
54
|
-
"https://t.link",
|
|
55
|
-
"https://my.tapni.com",
|
|
56
|
-
"https://my.tapni.co",
|
|
57
|
-
"https://dev.tapni.co",
|
|
58
|
-
"https://dev.tapni.com",
|
|
59
|
-
"https://auth.tapni.com",
|
|
60
|
-
"https://auth.tapni.co",
|
|
61
|
-
"https://mailsign.link",
|
|
62
|
-
"https://sign.tapni.com",
|
|
63
|
-
"https://qrcodetoolkit.com",
|
|
64
|
-
"https://qr.tapni.com",
|
|
65
|
-
"https://designer.tapni.com",
|
|
66
|
-
"https://designer-dev.tapni.com",
|
|
67
|
-
],
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
6
|
computed: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (this.$route.query.realm) this.$storage.realm = this.$route.query.realm;
|
|
91
|
-
|
|
92
|
-
EventBus.$on("updateLang", this.updateLang);
|
|
93
|
-
|
|
94
|
-
if (import.meta.env.NODE_ENV === "development") {
|
|
95
|
-
this.allowedOrigins.push("http://localhost:8082");
|
|
96
|
-
this.allowedOrigins.push("http://localhost:7777");
|
|
97
|
-
this.allowedOrigins.push("http://localhost:5173");
|
|
98
|
-
}
|
|
7
|
+
...mapState([
|
|
8
|
+
'$storex',
|
|
9
|
+
'refreshing',
|
|
10
|
+
'loggedInUserId',
|
|
11
|
+
'account',
|
|
12
|
+
'device',
|
|
13
|
+
'loggedInAccounts',
|
|
14
|
+
'ssoLang',
|
|
15
|
+
'display',
|
|
16
|
+
'redirect_uri',
|
|
17
|
+
'response_type',
|
|
18
|
+
'state',
|
|
19
|
+
'allowedOrigins'
|
|
20
|
+
]),
|
|
21
|
+
...mapGetters([
|
|
22
|
+
'isLoggedIn',
|
|
23
|
+
'renderView',
|
|
24
|
+
'appLanguage'
|
|
25
|
+
])
|
|
99
26
|
},
|
|
100
27
|
methods: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
snackbar.classList.add("show-snack");
|
|
128
|
-
errorSnack.classList.add("active-snack");
|
|
129
|
-
setTimeout(function () {
|
|
130
|
-
errorSnack.classList.remove("active-snack");
|
|
131
|
-
snackbar.classList.remove("show-snack");
|
|
132
|
-
}, 3000);
|
|
133
|
-
},
|
|
134
|
-
successSnack(message) {
|
|
135
|
-
let snackbar = document.getElementById("snackbar");
|
|
136
|
-
let successMessage = document.getElementById("successMessage");
|
|
137
|
-
let successSnack = document.getElementById("successSnack");
|
|
138
|
-
successMessage.innerHTML = message;
|
|
139
|
-
snackbar.classList.add("show-snack");
|
|
140
|
-
successSnack.classList.add("active-snack");
|
|
141
|
-
setTimeout(function () {
|
|
142
|
-
successSnack.classList.remove("active-snack");
|
|
143
|
-
snackbar.classList.remove("show-snack");
|
|
144
|
-
}, 3000);
|
|
145
|
-
},
|
|
146
|
-
closeSnacks() {
|
|
147
|
-
document.getElementById("snackbar").classList.remove("show-snack");
|
|
148
|
-
document.getElementById("successSnack").classList.remove("active-snack");
|
|
149
|
-
document.getElementById("errorSnack").classList.remove("active-snack");
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
async eventLog(data) {
|
|
153
|
-
const [err, response] = await to(
|
|
154
|
-
UserService.eventLog(data, this.$storage)
|
|
155
|
-
);
|
|
156
|
-
if (err) return this.errorHandler(err);
|
|
157
|
-
return response;
|
|
158
|
-
},
|
|
159
|
-
async maintenance() {
|
|
160
|
-
const [err, response] = await to(
|
|
161
|
-
axios.get("https://status.tapni.co/data/maintenance.json")
|
|
162
|
-
);
|
|
163
|
-
if (err) return console.error(err);
|
|
164
|
-
if (response) {
|
|
165
|
-
let maintenanceState = response.data;
|
|
166
|
-
if (typeof response.data === "string") {
|
|
167
|
-
maintenanceState = JSON.parse(response.data);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (maintenanceState.api && maintenanceState.api.maintenanceActive) {
|
|
171
|
-
location.href =
|
|
172
|
-
"https://t.link/maintenance?msg=" + maintenanceState.api.msg;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
async loginSetup(response) {
|
|
177
|
-
// Save Refresh Token
|
|
178
|
-
if (response.data.refreshToken)
|
|
179
|
-
this.setRefreshToken(response.data.refreshToken);
|
|
180
|
-
|
|
181
|
-
// Save Access Token
|
|
182
|
-
if (response.data.token) this.setToken(response.data.token);
|
|
183
|
-
|
|
184
|
-
this.setLoggedInUserId(response.data.data.id);
|
|
185
|
-
|
|
186
|
-
this.$storage.UserId = response.data.data.id;
|
|
187
|
-
this.$storage.username = response.data.data.username;
|
|
188
|
-
this.$storage.localUser = response.data.data;
|
|
189
|
-
|
|
190
|
-
if (response.isModal === true) {
|
|
191
|
-
this.setLoggedInAccounts([
|
|
192
|
-
{
|
|
193
|
-
id: response.data.data.id,
|
|
194
|
-
username: response.data.data.username,
|
|
195
|
-
refreshToken: response.data.refreshToken,
|
|
196
|
-
photo: response.data.data.photo,
|
|
197
|
-
},
|
|
198
|
-
]);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// await this.registerDevice();
|
|
202
|
-
// if (Capacitor.isNativePlatform()) initPushNotifications();
|
|
203
|
-
},
|
|
204
|
-
async switchAccount(username) {
|
|
205
|
-
this.$storage.username = username;
|
|
206
|
-
if (this.loggedInAccounts[username]) {
|
|
207
|
-
this.$storage.UserId = this.loggedInAccounts[username].id;
|
|
208
|
-
this.setLoggedInUserId(this.loggedInAccounts[username].id);
|
|
209
|
-
this.setRefreshToken(this.loggedInAccounts[username].refreshToken);
|
|
210
|
-
await this.refreshTokenAction({...this.loggedInAccounts[username], storage: this.$storage });
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
EventBus.$emit("ssoEvent", { name: "switchAccount", data: { username }, });
|
|
214
|
-
},
|
|
215
|
-
async refreshTokenAction(data) {
|
|
216
|
-
return new Promise(async (resolve, reject) => {
|
|
217
|
-
if (!data.refreshToken || this.refreshing) {
|
|
218
|
-
return resolve(null);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
this.refreshing = true;
|
|
222
|
-
const [err, response] = await to(
|
|
223
|
-
AuthService.refreshToken({
|
|
224
|
-
id: data.id,
|
|
225
|
-
refreshToken: data.refreshToken,
|
|
226
|
-
refreshTokenAction: true
|
|
227
|
-
}, data.storage)
|
|
228
|
-
);
|
|
229
|
-
if (err && err.response && err.response.data.error === "ACCESS_DENIED") {
|
|
230
|
-
this.logout(data.refreshToken, false);
|
|
231
|
-
return location.reload();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Set new access token
|
|
235
|
-
if (response && response.data) {
|
|
236
|
-
EventBus.$emit("setToken", response.data.token);
|
|
237
|
-
data.storage.token = response.data.token;
|
|
238
|
-
EventBus.$emit("ssoEvent", { name: "setStorage", data: data.storage });
|
|
239
|
-
resolve(response.data.token);
|
|
240
|
-
}
|
|
241
|
-
this.refreshing = false;
|
|
242
|
-
})
|
|
243
|
-
},
|
|
244
|
-
async login(data) {
|
|
245
|
-
const [err, response] = await to(AuthService.login(data, this.$storage));
|
|
246
|
-
if (err) return this.errorHandler(err);
|
|
247
|
-
if (response.data.success) {
|
|
248
|
-
if (this.display === "npm") {
|
|
249
|
-
this.loginSetup({ ...response, isModal: data.isModal });
|
|
250
|
-
await this.getLoggedInAccounts();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
this.loginSuccess({ ...response, isModal: data.isModal });
|
|
254
|
-
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
loginSuccess(response) {
|
|
259
|
-
if (this.display === "redirect") {
|
|
260
|
-
if (this.redirect_uri &&
|
|
261
|
-
!this.allowedOrigins.some((domain) =>
|
|
262
|
-
this.redirect_uri.startsWith(domain)
|
|
263
|
-
)
|
|
264
|
-
) {
|
|
265
|
-
return console.error("Redirect URI not allowed");
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
location.href = this.redirect_uri +
|
|
269
|
-
"?code=" +
|
|
270
|
-
response.data.auth_code +
|
|
271
|
-
"&state=" +
|
|
272
|
-
this.state;
|
|
273
|
-
} else if (this.display === "popup") {
|
|
274
|
-
this.allowedOrigins.forEach((domain) => {
|
|
275
|
-
window.parent?.postMessage(
|
|
276
|
-
{ code: response.data.auth_code, state: this.$route.query.state },
|
|
277
|
-
domain
|
|
278
|
-
);
|
|
279
|
-
});
|
|
280
|
-
} else if (this.display === "npm") {
|
|
281
|
-
EventBus.$emit('ssoEvent', {name: 'setLoading', data: true})
|
|
282
|
-
EventBus.$emit("ssoEvent", { name: "setStorage", data: this.$storage });
|
|
283
|
-
EventBus.$emit("ssoEvent", { name: "getUser", data: {username: response.data.data.username} });
|
|
284
|
-
|
|
285
|
-
if (response.isModal) {
|
|
286
|
-
EventBus.$emit("closeModal");
|
|
287
|
-
this.successSnack(this.ssoLang[this.appLanguage].success_login);
|
|
288
|
-
setTimeout(() => {
|
|
289
|
-
location.reload();
|
|
290
|
-
}, 1500);
|
|
291
|
-
}
|
|
292
|
-
this.$router.push("/" + response.data.data.username + "#edit");
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
async register(data) {
|
|
296
|
-
const [err, response] = await to(
|
|
297
|
-
AuthService.register(data, this.$storage)
|
|
298
|
-
);
|
|
299
|
-
if (err) return this.errorHandler(err);
|
|
300
|
-
return response;
|
|
301
|
-
},
|
|
302
|
-
async verify(data) {
|
|
303
|
-
const [err, response] = await to(AuthService.verify(data, this.$storage));
|
|
304
|
-
if (err) return this.errorHandler(err);
|
|
305
|
-
return response;
|
|
306
|
-
},
|
|
307
|
-
async reset(data) {
|
|
308
|
-
const [err, response] = await to(
|
|
309
|
-
AuthService.sendResetEmail(data, this.$storage)
|
|
310
|
-
);
|
|
311
|
-
if (err) return this.errorHandler(err);
|
|
312
|
-
if (response.data.success) {
|
|
313
|
-
this.successSnack(this.ssoLang[this.appLanguage].password_reset_success);
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
async exchangeAuthCode(data) {
|
|
317
|
-
const [err, response] = await to(AuthService.exchangeAuthCode(data, this.$storage));
|
|
318
|
-
if (err) return this.errorHandler(err);
|
|
319
|
-
await this.loginSetup(response);
|
|
320
|
-
await this.getLoggedInAccounts();
|
|
321
|
-
this.loginSuccess(response);
|
|
322
|
-
},
|
|
323
|
-
async changePassword(data) {
|
|
324
|
-
const [err, response] = await to(
|
|
325
|
-
AuthService.changePassword(data, this.$storage)
|
|
326
|
-
);
|
|
327
|
-
if (err) return this.errorHandler(err);
|
|
328
|
-
return response.data.success;
|
|
329
|
-
},
|
|
330
|
-
async newPassword(data) {
|
|
331
|
-
const [err, response] = await to(
|
|
332
|
-
UserService.newPassword(data, this.$storage)
|
|
333
|
-
);
|
|
334
|
-
if (err) return this.errorHandler(err);
|
|
335
|
-
return response.data.success;
|
|
336
|
-
},
|
|
337
|
-
async deleteAccount(data) {
|
|
338
|
-
const [err, response] = await to(
|
|
339
|
-
UserService.deleteAccount(data, this.$storage)
|
|
340
|
-
);
|
|
341
|
-
if (err) return this.errorHandler(err);
|
|
342
|
-
return response.data.success;
|
|
343
|
-
},
|
|
344
|
-
async registerDevice() {
|
|
345
|
-
const deviceID = await Device.getId();
|
|
346
|
-
const deviceInfo = await Device.getInfo();
|
|
347
|
-
let deviceData = {
|
|
348
|
-
device_id: deviceID.uuid,
|
|
349
|
-
platform: deviceInfo.platform,
|
|
350
|
-
device_info: {
|
|
351
|
-
model: deviceInfo.model,
|
|
352
|
-
manufacturer: deviceInfo.manufacturer,
|
|
353
|
-
operatingSystem: deviceInfo.operatingSystem,
|
|
354
|
-
osVersion: deviceInfo.osVersion,
|
|
355
|
-
isVirtual: deviceInfo.isVirtual,
|
|
356
|
-
webViewVersion: deviceInfo.webViewVersion,
|
|
357
|
-
},
|
|
358
|
-
};
|
|
359
|
-
const [err, response] = await to(
|
|
360
|
-
DeviceService.registerDevice(deviceData, this.$storage)
|
|
361
|
-
);
|
|
362
|
-
if (err) return this.errorHandler(err);
|
|
363
|
-
return response;
|
|
364
|
-
},
|
|
365
|
-
async addFcmToken(data) {
|
|
366
|
-
const [err, response] = await to(
|
|
367
|
-
DeviceService.addFcmToken(data, this.$storage)
|
|
368
|
-
);
|
|
369
|
-
if (err) return this.errorHandler(err);
|
|
370
|
-
return response;
|
|
371
|
-
},
|
|
372
|
-
async acceptCompanyInvitation(code) {
|
|
373
|
-
const [err, response] = await to(
|
|
374
|
-
CompanyService.acceptCompanyInvitation(code, this.$storage)
|
|
375
|
-
);
|
|
376
|
-
if (err) return this.errorHandler(err);
|
|
377
|
-
return response;
|
|
378
|
-
},
|
|
379
|
-
async logout(refreshToken, sendRequest = true) {
|
|
380
|
-
if (sendRequest && refreshToken) {
|
|
381
|
-
AuthService.logout({ token: refreshToken }, this.$storage);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (this.$storage) {
|
|
385
|
-
this.$storage.username = '';
|
|
386
|
-
this.$storage.UserId = '';
|
|
387
|
-
this.$storage.localUser = '';
|
|
388
|
-
this.setToken('');
|
|
389
|
-
}
|
|
390
|
-
this.setLoggedInUserId('');
|
|
391
|
-
|
|
392
|
-
const remainingRefreshTokens = this.unsetRefreshToken(refreshToken);
|
|
393
|
-
|
|
394
|
-
if (remainingRefreshTokens.length >= 1) {
|
|
395
|
-
Object.keys(this.loggedInAccounts).forEach((username) => {
|
|
396
|
-
if (this.loggedInAccounts[username].refreshToken === remainingRefreshTokens[0]) {
|
|
397
|
-
|
|
398
|
-
this.refreshTokenAction({...this.loggedInAccounts[username], storage: this.$storage }).then(() => {
|
|
399
|
-
this.setLoggedInUserId(this.loggedInAccounts[username].id);
|
|
400
|
-
if (this.$storage) {
|
|
401
|
-
this.$storage.username = username;
|
|
402
|
-
this.$storage.UserId = this.loggedInAccounts[username].id;
|
|
403
|
-
}
|
|
404
|
-
this.getLoggedInAccounts();
|
|
405
|
-
this.$router.push("/" + username);
|
|
406
|
-
|
|
407
|
-
setTimeout(() => {
|
|
408
|
-
location.reload();
|
|
409
|
-
}, 1500)
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
} else {
|
|
414
|
-
this.setUser(null);
|
|
415
|
-
this.$router.push("/welcome");
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
async getCompanyBySSOEmail(data) {
|
|
419
|
-
const [err, response] = await to(
|
|
420
|
-
CompanyService.getBySSOEmail(data.email, this.$storage)
|
|
421
|
-
);
|
|
422
|
-
if (err) return this.errorHandler(err);
|
|
423
|
-
if (response.data.success) {
|
|
424
|
-
return response.data;
|
|
425
|
-
}
|
|
426
|
-
},
|
|
427
|
-
async getLoggedInAccounts(refreshTokens) {
|
|
428
|
-
if (!refreshTokens) refreshTokens = this.getRefreshTokens();
|
|
429
|
-
if (refreshTokens && refreshTokens.length >= 1) {
|
|
430
|
-
const [err, response] = await to(
|
|
431
|
-
AuthService.getLoggedInAccounts({ refreshTokens }, this.$storage)
|
|
432
|
-
);
|
|
433
|
-
if (err) return this.errorHandler(err);
|
|
434
|
-
if (response && response.data && response.data.success) {
|
|
435
|
-
this.setLoggedInAccounts(response.data.accounts);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
async loginUsingQR(data) {
|
|
440
|
-
const [err, response] = await to(
|
|
441
|
-
UserService.loginUsingQR(data, this.$storage)
|
|
442
|
-
);
|
|
443
|
-
if (err) return this.errorHandler(err);
|
|
444
|
-
return response.data.success;
|
|
445
|
-
},
|
|
446
|
-
setLoggedInAccounts(accounts) {
|
|
447
|
-
this.loggedInAccounts = {};
|
|
448
|
-
accounts.forEach((account) => {
|
|
449
|
-
this.loggedInAccounts[account.username] = account;
|
|
450
|
-
});
|
|
451
|
-
EventBus.$emit("ssoEvent", { name: "setLoggedInAccounts", data: accounts });
|
|
452
|
-
},
|
|
453
|
-
setLoggedInUserId(id) {
|
|
454
|
-
this.loggedInUserId = id;
|
|
455
|
-
},
|
|
456
|
-
setUser(user) {
|
|
457
|
-
this.ssoUser = user;
|
|
458
|
-
if (
|
|
459
|
-
this.$storage &&
|
|
460
|
-
this.ssoUser &&
|
|
461
|
-
this.$storage.username === this.ssoUser.username
|
|
462
|
-
) {
|
|
463
|
-
this.appLanguage = user.ssoLang;
|
|
464
|
-
}
|
|
465
|
-
},
|
|
466
|
-
getRefreshTokens() {
|
|
467
|
-
if (this.$storage && this.$storage.refreshTokens) return this.$storage.refreshTokens.split(',')
|
|
468
|
-
else return [];
|
|
469
|
-
},
|
|
470
|
-
setRefreshToken(token) {
|
|
471
|
-
// Get all refresh tokens
|
|
472
|
-
let refreshTokens = this.getRefreshTokens();
|
|
473
|
-
|
|
474
|
-
// If token exists, add to the top of the list
|
|
475
|
-
if (!refreshTokens.includes(token)) {
|
|
476
|
-
refreshTokens.unshift(token);
|
|
477
|
-
} else {
|
|
478
|
-
// Move token to the top of the list
|
|
479
|
-
refreshTokens = refreshTokens.filter((t) => t !== token);
|
|
480
|
-
refreshTokens.unshift(token);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
this.$storage.refreshTokens = refreshTokens.join(",");
|
|
484
|
-
},
|
|
485
|
-
unsetRefreshToken(refreshToken) {
|
|
486
|
-
// Get all refresh tokens
|
|
487
|
-
let refreshTokens = this.getRefreshTokens();
|
|
488
|
-
|
|
489
|
-
refreshTokens = refreshTokens.filter((t) => t !== refreshToken);
|
|
490
|
-
|
|
491
|
-
if (this.$storage) {
|
|
492
|
-
this.$storage.refreshTokens = refreshTokens.join(",");
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
return refreshTokens;
|
|
496
|
-
},
|
|
497
|
-
setToken(token) {
|
|
498
|
-
this.$storage.token = token;
|
|
499
|
-
this.token = token;
|
|
500
|
-
},
|
|
501
|
-
setUserID(userID) {
|
|
502
|
-
this.$storage.UserId = userID;
|
|
503
|
-
},
|
|
504
|
-
updateLang(lang) {
|
|
505
|
-
this.lang = lang;
|
|
506
|
-
}
|
|
28
|
+
...mapActions([
|
|
29
|
+
'setLoggedInAccounts',
|
|
30
|
+
'setLoggedInUserId',
|
|
31
|
+
'getRefreshTokens',
|
|
32
|
+
'setRefreshToken',
|
|
33
|
+
'unsetRefreshToken',
|
|
34
|
+
'setToken',
|
|
35
|
+
'setUserID',
|
|
36
|
+
'updateLang',
|
|
37
|
+
'login',
|
|
38
|
+
'register',
|
|
39
|
+
'verify',
|
|
40
|
+
'reset',
|
|
41
|
+
'exchangeAuthCode',
|
|
42
|
+
'changePassword',
|
|
43
|
+
'newPassword',
|
|
44
|
+
'deleteAccount',
|
|
45
|
+
'registerDevice',
|
|
46
|
+
'addFcmToken',
|
|
47
|
+
'acceptCompanyInvitation',
|
|
48
|
+
'logout',
|
|
49
|
+
'getCompanyBySSOEmail',
|
|
50
|
+
'getLoggedInAccounts',
|
|
51
|
+
'loginUsingQR',
|
|
52
|
+
'getAccountSettings',
|
|
53
|
+
])
|
|
507
54
|
},
|
|
508
55
|
watch: {
|
|
509
56
|
"$route.query": {
|
|
510
57
|
handler: function handler() {
|
|
511
|
-
if (this.$route.query.redirect_uri)
|
|
512
|
-
|
|
513
|
-
if (this.$route.query.
|
|
514
|
-
if (this.$route.query.
|
|
515
|
-
if (this.$route.query.
|
|
516
|
-
this.response_type = this.$route.query.response_type;
|
|
517
|
-
if (this.$route.query.realm)
|
|
518
|
-
this.$storage.realm = this.$route.query.realm;
|
|
519
|
-
if (this.$route.query.qrLogin) this.changeLoginToQr();
|
|
58
|
+
if (this.$route.query.redirect_uri) this.$store.dispatch('setRedirectUri', this.$route.query.redirect_uri);
|
|
59
|
+
if (this.$route.query.display) this.$store.dispatch('setDisplay', this.$route.query.display);
|
|
60
|
+
if (this.$route.query.state) this.$store.dispatch('setState', this.$route.query.state)
|
|
61
|
+
if (this.$route.query.response_type) this.$store.dispatch('setResponseType', this.$route.query.response_type);
|
|
62
|
+
if (this.$route.query.realm && this.$storage) this.$store.dispatch('setRealm', this.$route.query.realm);
|
|
520
63
|
},
|
|
521
64
|
deep: true,
|
|
522
65
|
},
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
return 'https://www.facebook.com/v16.0/dialog/oauth?client_id=202577611527680&state={"oauth":"facebook"}&response_type=code%20granted_scopes&scope=email&redirect_uri=https://' + window.location.host + '/login'
|
|
35
35
|
},
|
|
36
36
|
displayFacebookLogin () {
|
|
37
|
-
return false
|
|
37
|
+
return false;
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
methods: {
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
|
|
52
52
|
if (user && user.accessToken) {
|
|
53
53
|
|
|
54
|
-
const [err, response] = await to(AuthService.facebookSDK(user, this.$
|
|
54
|
+
const [err, response] = await to(AuthService.facebookSDK(user, this.$storex))
|
|
55
55
|
if (err) {
|
|
56
56
|
this.facebookLoad = false
|
|
57
57
|
EventBus.$emit('ssoEvent', {name: 'setLoading', data: false})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {Capacitor} from '@capacitor/core';
|
|
2
|
-
|
|
2
|
+
import { EventBus } from "../store/event-bus";
|
|
3
3
|
export default {
|
|
4
4
|
computed: {
|
|
5
5
|
home() {
|
|
6
|
-
if (this.$
|
|
7
|
-
if (import.meta.env.VITE_APP_MODE === 'npm') return '/' + this.$
|
|
8
|
-
if (import.meta.env.VITE_APP_MODE === 'redirect') return '
|
|
6
|
+
if (this.$storex && this.$storex.token && this.$storex.username) {
|
|
7
|
+
if (import.meta.env.VITE_APP_MODE === 'npm') return '/' + this.$storex.username
|
|
8
|
+
if (import.meta.env.VITE_APP_MODE === 'redirect') return '/account'
|
|
9
9
|
} else return '/welcome'
|
|
10
10
|
},
|
|
11
11
|
isAndroid(){
|
|
@@ -37,6 +37,7 @@ export default {
|
|
|
37
37
|
) {
|
|
38
38
|
this.logout();
|
|
39
39
|
}
|
|
40
|
+
|
|
40
41
|
// Link click network error bug fix
|
|
41
42
|
if (!error.response.data.error.includes('Network Error') && !error.response.data.error.includes('Cannot read properties')) {
|
|
42
43
|
this.errorSnack(error.response.data.error)
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
computed: {
|
|
13
13
|
displayGoogleLogin () {
|
|
14
|
-
return
|
|
14
|
+
return true;
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
mounted () {
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
// Code Login
|
|
35
35
|
if (this.display === 'popup') user.response_type = 'code';
|
|
36
36
|
|
|
37
|
-
const [err, response] = await to(AuthService.googleSDK(user, this.$
|
|
37
|
+
const [err, response] = await to(AuthService.googleSDK(user, this.$storex))
|
|
38
38
|
if (err) {
|
|
39
39
|
this.googleLoad = false
|
|
40
40
|
EventBus.$emit('ssoEvent', {name: 'setLoading', data: false})
|