fix(web): discard failed auth process

This commit is contained in:
Ali BARIN
2022-10-30 22:27:27 +01:00
parent c2b020fc94
commit 9c40bc5863
2 changed files with 12 additions and 2 deletions

View File

@@ -71,6 +71,8 @@ export default function AddAppConnection(props: AddAppConnectionProps): React.Re
const error = err as Error;
console.log(error);
setErrorMessage(error.message);
setInProgress(false);
break;
}

View File

@@ -15,7 +15,7 @@ const processMutation = async (step: IAuthenticationStep, variables: IJSONObject
context: {
autoSnackbar: false,
},
});
});
const responseData = mutationResponse.data[step.name];
return responseData;
@@ -38,13 +38,20 @@ function getObjectOfEntries(iterator: any) {
}
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 url = variables.url;
const popup = window.open(url as string, '_blank', windowFeatures) as WindowProxy;
popup?.focus();
const closeCheckIntervalId = setInterval(() => {
if (popup.closed) {
clearInterval(closeCheckIntervalId);
reject({ message: 'Error occured while verifying credentials!' });
}
}, 1000)
const messageHandler = async (event: MessageEvent) => {
if (event.data.source !== 'automatisch') {
return;
@@ -53,6 +60,7 @@ const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject)
const data = parseUrlSearchParams(event);
window.removeEventListener('message', messageHandler);
clearInterval(closeCheckIntervalId);
resolve(data);
};