Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web2/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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}`;
Expand Down Expand Up @@ -114,4 +115,5 @@ export function hasValidToken() {
export function clearTokens() {
localStorage.removeItem(TOKEN_KEY);
localStorage.removeItem('code_verifier');
localStorage.setItem('force_show_dialog', 'true');
}
6 changes: 5 additions & 1 deletion web2/js/views/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down