From 03d2c7b817b54e662da58db38e66e96f4f97a8db Mon Sep 17 00:00:00 2001 From: Sam <78538841+spwoodcock@users.noreply.github.com> Date: Fri, 2 Feb 2024 19:15:05 +0000 Subject: [PATCH] fix: create popup outside of async request (fix ios login) (#1167) --- src/frontend/src/utilfunctions/login.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utilfunctions/login.ts b/src/frontend/src/utilfunctions/login.ts index 0d6f2072e6..185e0c7a03 100644 --- a/src/frontend/src/utilfunctions/login.ts +++ b/src/frontend/src/utilfunctions/login.ts @@ -1,15 +1,20 @@ import { createPopup } from '@/utilfunctions/createPopup'; export const createLoginWindow = (redirectTo) => { + // Create popup outside of request (required for Safari security) + const popup = createPopup('OSM Auth', ''); + fetch(`${import.meta.env.VITE_API_URL}/auth/osm_login/`) .then((resp) => resp.json()) .then((resp) => { - const popup = createPopup('OSM auth', resp.login_url); if (!popup) { console.warn('Popup blocked or unavailable.'); return; } + // Set URL for popup from response + popup.location = resp.login_url; + // Get OAuth2 authorization url, extract state const authUrl = new URL(resp.login_url); const authParams = new URLSearchParams(authUrl.search);