update logging
This commit is contained in:
@ -1,20 +1,22 @@
|
||||
import { log } from '$lib/log';
|
||||
import { Logger } from '$lib/log';
|
||||
import { SpotifyPlaylistAdder } from '$lib/server/playlist/spotifyPlaylistAdder';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
const logger = new Logger('SpotifyAuth');
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
const adder = new SpotifyPlaylistAdder();
|
||||
let redirectUri = url;
|
||||
if (url.hostname === 'localhost') {
|
||||
redirectUri.hostname = '127.0.0.1';
|
||||
}
|
||||
log.debug(url.searchParams, url.hostname);
|
||||
logger.debug(url.searchParams, url.hostname);
|
||||
if (url.searchParams.has('code')) {
|
||||
await adder.receivedAuthCode(url.searchParams.get('code') || '', url);
|
||||
redirect(307, '/');
|
||||
} else if (url.searchParams.has('error')) {
|
||||
log.error('received error', url.searchParams.get('error'));
|
||||
logger.error('received error', url.searchParams.get('error'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -23,6 +25,6 @@ export const load: PageServerLoad = async ({ url }) => {
|
||||
}
|
||||
|
||||
const authUrl = adder.constructAuthUrl(url);
|
||||
log.debug('+page.server.ts', authUrl.toString());
|
||||
logger.debug('+page.server.ts', authUrl.toString());
|
||||
redirect(307, authUrl);
|
||||
};
|
||||
|
@ -1,16 +1,18 @@
|
||||
import { log } from '$lib/log';
|
||||
import { Logger } from '$lib/log';
|
||||
import { YoutubePlaylistAdder } from '$lib/server/playlist/ytPlaylistAdder';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
const logger = new Logger('YT Auth');
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
const adder = new YoutubePlaylistAdder();
|
||||
if (url.searchParams.has('code')) {
|
||||
log.debug(url.searchParams);
|
||||
logger.debug(url.searchParams);
|
||||
await adder.receivedAuthCode(url.searchParams.get('code') || '', url);
|
||||
redirect(307, '/');
|
||||
} else if (url.searchParams.has('error')) {
|
||||
log.error('received error', url.searchParams.get('error'));
|
||||
logger.error('received error', url.searchParams.get('error'));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -19,6 +21,6 @@ export const load: PageServerLoad = async ({ url }) => {
|
||||
}
|
||||
|
||||
const authUrl = adder.constructAuthUrl(url);
|
||||
log.debug('+page.server.ts', authUrl.toString());
|
||||
logger.debug('+page.server.ts', authUrl.toString());
|
||||
redirect(307, authUrl);
|
||||
};
|
||||
|
Reference in New Issue
Block a user