diff --git a/web2/js/auth.js b/web2/js/auth.js index 283f2ac..e2d0b44 100644 --- a/web2/js/auth.js +++ b/web2/js/auth.js @@ -21,7 +21,7 @@ function base64urlEncode(buffer) { .replace(/\//g, '_'); } -export async function redirectToSpotifyAuth() { +export async function redirectToSpotifyAuth(showDialog = false) { const codeVerifier = generateRandomString(64); localStorage.setItem('code_verifier', codeVerifier); @@ -35,6 +35,7 @@ export async function redirectToSpotifyAuth() { redirect_uri: SPOTIFY_REDIRECT_URI, code_challenge_method: 'S256', code_challenge: codeChallenge, + show_dialog: String(showDialog), }); window.location.href = `https://accounts.spotify.com/authorize?${params}`; @@ -114,4 +115,5 @@ export function hasValidToken() { export function clearTokens() { localStorage.removeItem(TOKEN_KEY); localStorage.removeItem('code_verifier'); + localStorage.setItem('force_show_dialog', 'true'); } diff --git a/web2/js/views/landing.js b/web2/js/views/landing.js index b1ac714..350d098 100644 --- a/web2/js/views/landing.js +++ b/web2/js/views/landing.js @@ -13,7 +13,11 @@ export function renderLanding(container) { el('p', { class: 'hero-prompt' }, 'Login with your Spotify account to get started'), el('button', { class: 'btn btn--primary btn--lg', - on: { click: () => redirectToSpotifyAuth() }, + on: { click: () => { + const forceDialog = localStorage.getItem('force_show_dialog') === 'true'; + localStorage.removeItem('force_show_dialog'); + redirectToSpotifyAuth(forceDialog); + }}, }, 'Login with Spotify'), el('div', { class: 'hero-trust' }, el('p', {}, 'Sorting playlists since 2012 ยท Millions of playlists sorted'),