hardset cookie

This commit is contained in:
TPN 2024-06-05 16:17:20 +05:30
parent d5194d21e8
commit f0bfccaa6f
No known key found for this signature in database
GPG Key ID: 40AE091637892B91
1 changed files with 13 additions and 7 deletions

View File

@ -10,14 +10,20 @@ export async function login(
pass: string,
ctx: ShowScrapeContext | MovieScrapeContext,
): Promise<string | null> {
const req = await ctx.proxiedFetcher.full<string>('/login', {
baseUrl,
method: 'POST',
body: new URLSearchParams({ user, pass, action: 'login' }),
readHeaders: ['Set-Cookie'],
});
let req;
if (user && pass)
req = await ctx.proxiedFetcher.full<string>('/login', {
baseUrl,
method: 'POST',
body: new URLSearchParams({ user, pass, action: 'login' }),
readHeaders: ['Set-Cookie'],
});
const cookies = parseSetCookie(req.headers.get('Set-Cookie') || '');
const cookies = parseSetCookie(
req?.headers.get('Set-Cookie') ||
// we don't wan't our creds to be in the code
'PHPSESSID=phmje3cqeft42rckf8mj7illhc;',
);
return cookies.PHPSESSID.value;
}