Skip to content

Commit

Permalink
fix: create popup outside of async request (fix ios login) (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock authored Feb 2, 2024
1 parent 304863e commit 03d2c7b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/frontend/src/utilfunctions/login.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 03d2c7b

Please sign in to comment.