introduce data.type=config_info for the new postMessage in auth
This commit is contained in:
@@ -161,6 +161,7 @@ describe('showLoginPopup', () => {
|
||||
source: popupMock,
|
||||
origin: 'origin',
|
||||
data: {
|
||||
type: 'config_info',
|
||||
targetOrigin: 'http://localhost',
|
||||
},
|
||||
} as MessageEvent);
|
||||
@@ -198,6 +199,7 @@ describe('showLoginPopup', () => {
|
||||
source: popupMock,
|
||||
origin: 'origin',
|
||||
data: {
|
||||
type: 'config_info',
|
||||
targetOrigin: 'http://differenthost',
|
||||
},
|
||||
} as MessageEvent);
|
||||
|
||||
@@ -95,7 +95,7 @@ export function showLoginPopup(options: LoginPopupOptions): Promise<any> {
|
||||
}
|
||||
const { data } = event;
|
||||
|
||||
if (data.targetOrigin) {
|
||||
if (data.type === 'config_info') {
|
||||
targetOrigin = data.targetOrigin;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export const postMessageResponse = (
|
||||
const script = `
|
||||
var authResponse = decodeURIComponent('${base64Data}');
|
||||
var origin = decodeURIComponent('${base64Origin}');
|
||||
var originInfo = {'targetOrigin': origin};
|
||||
var originInfo = {'type': 'config_info', 'targetOrigin': origin};
|
||||
(window.opener || window.parent).postMessage(originInfo, '*');
|
||||
(window.opener || window.parent).postMessage(JSON.parse(authResponse), origin);
|
||||
window.close();
|
||||
|
||||
Reference in New Issue
Block a user