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