mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
small refinment
This commit is contained in:
@@ -508,13 +508,14 @@ export async function uploadGoogleSheetClientFile(req, res) {
|
||||
|
||||
/**
|
||||
* @returns link to sheet auth url
|
||||
* @method GET
|
||||
*/
|
||||
export async function sheetAuthUrl(req, res) {
|
||||
const successful = await Sheet.openAuthServer();
|
||||
if (successful === false) {
|
||||
res.status(500).send('bad');
|
||||
const authUrl = await Sheet.openAuthServer();
|
||||
if (!authUrl) {
|
||||
res.status(500).send('Unable to start auth server');
|
||||
} else {
|
||||
res.status(200).send(successful);
|
||||
res.status(200).send(authUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ class sheet {
|
||||
* @returns {Promise<string | false>} - returns url to serve on success
|
||||
* @throws
|
||||
*/
|
||||
public async openAuthServer(): Promise<string | false> {
|
||||
public async openAuthServer(): Promise<string | null> {
|
||||
//TODO: this only works on local networks
|
||||
if (sheet.authUrl) {
|
||||
clearTimeout(this.authServerTimeout);
|
||||
@@ -278,13 +278,13 @@ class sheet {
|
||||
logger.error(LogOrigin.Server, `${err}`),
|
||||
);
|
||||
if (!creadFile) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
const keyFile = JSON.parse(creadFile);
|
||||
const keys = keyFile.installed || keyFile.web;
|
||||
if (!keys.redirect_uris || keys.redirect_uris.length === 0) {
|
||||
logger.error(LogOrigin.Server, `${invalidRedirectUri}`);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
// create an oAuth client to authorize the API call
|
||||
|
||||
Reference in New Issue
Block a user