fix: actions open in new link if in connect iframe

This commit is contained in:
Zack Spear
2023-08-11 16:02:30 -07:00
parent 8097333510
commit 286cc08933
4 changed files with 104 additions and 62 deletions

View File

@@ -30,57 +30,81 @@ export const useAccountStore = defineStore('account', () => {
// Actions
const recover = () => {
console.debug('[accountStore.recover]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'recover',
}]);
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'recover',
}],
serverStore.inIframe,
);
};
const replace = () => {
console.debug('[accountStore.replace]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'replace',
}]);
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'replace',
}],
serverStore.inIframe,
);
};
const signIn = () => {
console.debug('[accountStore.signIn]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'signIn',
}]);
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'signIn',
}],
serverStore.inIframe,
);
};
const signOut = () => {
console.debug('[accountStore.accountStore.signOut]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'signOut',
}]);
console.debug('[accountStore.signOut]');
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'signOut',
}],
serverStore.inIframe,
);
};
const trialExtend = () => {
console.debug('[accountStore.accountStore.trialExtend]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'trialExtend',
}]);
console.debug('[accountStore.trialExtend]');
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'trialExtend',
}],
serverStore.inIframe,
);
};
const trialStart = () => {
console.debug('[accountStore.accountStore.trialStart]');
callbackStore.send(ACCOUNT_CALLBACK.toString(), [{
server: {
...serverStore.serverAccountPayload,
},
type: 'trialStart',
}]);
console.debug('[accountStore.trialStart]');
callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
...serverStore.serverAccountPayload,
},
type: 'trialStart',
}],
serverStore.inIframe,
);
};
/**
* @description Update myservers.cfg for both Sign In & Sign Out

View File

@@ -114,8 +114,8 @@ export const useCallbackStoreGeneric = (
const encryptionKey = import.meta.env.VITE_CALLBACK_KEY;
const defaultSendType = 'fromUpc';
const send = (url: string, payload: SendPayloads, sendType?: 'fromUpc' | 'forUpc') => {
console.debug('[callback.send]');
const send = (url: string, payload: SendPayloads, newTab: boolean = false, sendType?: 'fromUpc' | 'forUpc') => {
console.debug('[callback.send]', { url, payload, sendType, newTab });
try {
const stringifiedData = JSON.stringify({
actions: [
@@ -129,6 +129,11 @@ export const useCallbackStoreGeneric = (
const destinationUrl = new URL(url);
destinationUrl.searchParams.set('data', encodeURI(encryptedMessage));
console.debug('[callback.send]', encryptedMessage, destinationUrl);
if (newTab) {
window.open(destinationUrl.toString(), '_blank');
return;
}
window.location.href = destinationUrl.toString();
} catch (error) {
console.error(error);

View File

@@ -15,31 +15,43 @@ export const usePurchaseStore = defineStore('purchase', () => {
const serverStore = useServerStore();
const redeem = () => {
console.debug('[redeem]');
callbackStore.send(PURCHASE_CALLBACK.toString(), [{
server: {
...serverStore.serverPurchasePayload,
},
type: 'redeem',
}]);
console.debug('[serverStore.redeem]');
callbackStore.send(
PURCHASE_CALLBACK.toString(),
[{
server: {
...serverStore.serverPurchasePayload,
},
type: 'redeem',
}],
serverStore.inIframe,
);
};
const purchase = () => {
console.debug('[purchase]');
callbackStore.send(PURCHASE_CALLBACK.toString(), [{
server: {
...serverStore.serverPurchasePayload,
},
type: 'purchase',
}]);
console.debug('[serverStore.purchase]');
callbackStore.send(
PURCHASE_CALLBACK.toString(),
[{
server: {
...serverStore.serverPurchasePayload,
},
type: 'purchase',
}],
serverStore.inIframe,
);
};
const upgrade = () => {
console.debug('[upgrade]');
callbackStore.send(PURCHASE_CALLBACK.toString(), [{
server: {
...serverStore.serverPurchasePayload,
},
type: 'upgrade',
}]);
console.debug('[serverStore.upgrade]');
callbackStore.send(
PURCHASE_CALLBACK.toString(),
[{
server: {
...serverStore.serverPurchasePayload,
},
type: 'upgrade',
}],
serverStore.inIframe,
);
};
return {

View File

@@ -876,6 +876,7 @@ export const useServerStore = defineStore('server', () => {
deviceCount,
expireTime,
guid,
inIframe,
locale,
lanIp,
name,