mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-06 16:03:52 +00:00
extend authServer timeout if opened again
This commit is contained in:
@@ -10,6 +10,8 @@ import {
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
} from '@chakra-ui/react';
|
||||
import { IoArrowDownCircleOutline } from '@react-icons/all-files/io5/IoArrowDownCircleOutline';
|
||||
import { IoArrowUpCircleOutline } from '@react-icons/all-files/io5/IoArrowUpCircleOutline';
|
||||
import { IoCheckmarkCircleOutline } from '@react-icons/all-files/io5/IoCheckmarkCircleOutline';
|
||||
import { IoCloseCircleOutline } from '@react-icons/all-files/io5/IoCloseCircleOutline';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
@@ -106,7 +108,8 @@ export default function SheetsModal(props: SheetsModalProps) {
|
||||
const handleAuthenticate = () => {
|
||||
getSheetsAuthUrl().then((data) => {
|
||||
if (data != 'bad') {
|
||||
window.open(data, '_blank', 'noreferrer');
|
||||
const authWindow = window.open(data, '_blank', 'noreferrer');
|
||||
//TODO: can we detect when this window is closed
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -224,10 +227,20 @@ export default function SheetsModal(props: SheetsModalProps) {
|
||||
<ModalFooter>
|
||||
{!rundown && (
|
||||
<div>
|
||||
<Button variant='ontime-subtle-on-light' padding='0 2em' onClick={handlePullData}>
|
||||
<Button
|
||||
variant='ontime-subtle-on-light'
|
||||
padding='0 2em'
|
||||
onClick={handlePullData}
|
||||
rightIcon={<IoArrowDownCircleOutline />}
|
||||
>
|
||||
Pull data
|
||||
</Button>
|
||||
<Button variant='ontime-subtle-on-light' padding='0 2em' onClick={handlePushData}>
|
||||
<Button
|
||||
variant='ontime-subtle-on-light'
|
||||
padding='0 2em'
|
||||
onClick={handlePushData}
|
||||
rightIcon={<IoArrowUpCircleOutline />}
|
||||
>
|
||||
Push data
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -308,6 +308,7 @@ class sheet {
|
||||
};
|
||||
}
|
||||
|
||||
private authServerTimeout;
|
||||
/**
|
||||
* create local Auth Server - returns url to serve on success
|
||||
* @returns {Promise<string | false>}
|
||||
@@ -316,6 +317,14 @@ class sheet {
|
||||
public async openAuthServer(): Promise<string | false> {
|
||||
//TODO: this only works on local networks
|
||||
if (sheet.authUrl) {
|
||||
clearTimeout(this.authServerTimeout);
|
||||
this.authServerTimeout = setTimeout(
|
||||
() => {
|
||||
sheet.authUrl = null;
|
||||
server.unref;
|
||||
},
|
||||
2 * 60 * 1000,
|
||||
);
|
||||
return sheet.authUrl;
|
||||
}
|
||||
const creadFile = await readFile(this.client_secret, 'utf-8').catch((err) =>
|
||||
@@ -396,7 +405,7 @@ class sheet {
|
||||
scope: this.scope,
|
||||
});
|
||||
sheet.authUrl = authorizeUrl;
|
||||
setTimeout(
|
||||
this.authServerTimeout = setTimeout(
|
||||
() => {
|
||||
sheet.authUrl = null;
|
||||
server.unref;
|
||||
|
||||
Reference in New Issue
Block a user