return auth url on first clik

This commit is contained in:
arc-alex
2023-11-18 21:15:39 +01:00
parent 785695c01c
commit fe67e65a95
+3 -4
View File
@@ -143,7 +143,6 @@ 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
//FIXME: the authUrl is not returnd before the second call
if (sheet.authUrl) { if (sheet.authUrl) {
return sheet.authUrl; return sheet.authUrl;
} }
@@ -213,7 +212,8 @@ class sheet {
} else if (redirectUri.port !== '') { } else if (redirectUri.port !== '') {
listenPort = Number(redirectUri.port); listenPort = Number(redirectUri.port);
} }
server.listen(listenPort, () => { //FIXME: the server might not start correctly
server.listen(listenPort, () => {});
const address = server.address(); const address = server.address();
if (typeof address !== 'string') { if (typeof address !== 'string') {
redirectUri.port = String(address.port); redirectUri.port = String(address.port);
@@ -225,8 +225,6 @@ class sheet {
scope: this.scope, scope: this.scope,
}); });
sheet.authUrl = authorizeUrl; sheet.authUrl = authorizeUrl;
return authorizeUrl;
});
setTimeout( setTimeout(
() => { () => {
sheet.authUrl = null; sheet.authUrl = null;
@@ -234,6 +232,7 @@ class sheet {
}, },
2 * 60 * 1000, 2 * 60 * 1000,
); );
return authorizeUrl;
} }
} }