fix(web): discard failed auth process
This commit is contained in:
@@ -71,6 +71,8 @@ export default function AddAppConnection(props: AddAppConnectionProps): React.Re
|
|||||||
const error = err as Error;
|
const error = err as Error;
|
||||||
console.log(error);
|
console.log(error);
|
||||||
setErrorMessage(error.message);
|
setErrorMessage(error.message);
|
||||||
|
setInProgress(false);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ const processMutation = async (step: IAuthenticationStep, variables: IJSONObject
|
|||||||
context: {
|
context: {
|
||||||
autoSnackbar: false,
|
autoSnackbar: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const responseData = mutationResponse.data[step.name];
|
const responseData = mutationResponse.data[step.name];
|
||||||
|
|
||||||
return responseData;
|
return responseData;
|
||||||
@@ -38,13 +38,20 @@ function getObjectOfEntries(iterator: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject) => {
|
const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve, reject) => {
|
||||||
const windowFeatures = 'toolbar=no, titlebar=no, menubar=no, width=500, height=700, top=100, left=100';
|
const windowFeatures = 'toolbar=no, titlebar=no, menubar=no, width=500, height=700, top=100, left=100';
|
||||||
const url = variables.url;
|
const url = variables.url;
|
||||||
|
|
||||||
const popup = window.open(url as string, '_blank', windowFeatures) as WindowProxy;
|
const popup = window.open(url as string, '_blank', windowFeatures) as WindowProxy;
|
||||||
popup?.focus();
|
popup?.focus();
|
||||||
|
|
||||||
|
const closeCheckIntervalId = setInterval(() => {
|
||||||
|
if (popup.closed) {
|
||||||
|
clearInterval(closeCheckIntervalId);
|
||||||
|
reject({ message: 'Error occured while verifying credentials!' });
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
const messageHandler = async (event: MessageEvent) => {
|
const messageHandler = async (event: MessageEvent) => {
|
||||||
if (event.data.source !== 'automatisch') {
|
if (event.data.source !== 'automatisch') {
|
||||||
return;
|
return;
|
||||||
@@ -53,6 +60,7 @@ const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject)
|
|||||||
const data = parseUrlSearchParams(event);
|
const data = parseUrlSearchParams(event);
|
||||||
window.removeEventListener('message', messageHandler);
|
window.removeEventListener('message', messageHandler);
|
||||||
|
|
||||||
|
clearInterval(closeCheckIntervalId);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user