(core) Google auth endpoint has not responded with auth code

Summary:
Google Auth popup wasn't able to resolve origin from gristConfig.
Moving this reponsability to server side, where it gets calculated from initial request.

Test Plan: n/a

Reviewers: dsagal, paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2935
This commit is contained in:
Jarosław Sadziński
2021-07-21 18:38:57 +02:00
parent 08295a696b
commit 291bcd17ff
5 changed files with 20 additions and 18 deletions

View File

@@ -51,12 +51,10 @@ export function makeGristConfig(homeUrl: string|null, extra: Partial<GristLoadCo
* Primary used for Google Auth Grist's endpoint, but can be used in future in any other server side
* authentication flow.
*/
export function makeMessagePage(server: GristServer, staticDir: string) {
export function makeMessagePage(staticDir: string) {
return async (req: express.Request, resp: express.Response, message: any) => {
const config = server.getGristConfig();
const fileContent = await fse.readFile(path.join(staticDir, "message.html"), 'utf8');
const content = fileContent
.replace("<!-- INSERT CONFIG -->", `<script>window.gristConfig = ${JSON.stringify(config)};</script>`)
.replace("<!-- INSERT MESSAGE -->", `<script>window.message = ${JSON.stringify(message)};</script>`);
resp.status(200).type('html').send(content);
};