chore(remote_judger): prevent multiple request in ensureLogin()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-19 08:56:18 +08:00
parent d824955ebe
commit c2fdca91cd
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -148,7 +148,7 @@ export default class CodeforcesProvider implements IBasicProvider {
} }
async getCsrfToken(url: string, referer = '') { async getCsrfToken(url: string, referer = '') {
const { text: html } = await this.get(url).set('Referer', referer); const { text: html, header } = await this.get(url).set('Referer', referer);
const { const {
window: { document }, window: { document },
} = new JSDOM(html); } = new JSDOM(html);
@ -164,6 +164,7 @@ export default class CodeforcesProvider implements IBasicProvider {
)?.getAttribute('content'), )?.getAttribute('content'),
ftaa, ftaa,
bfaa, bfaa,
header,
]; ];
} }
@ -198,8 +199,7 @@ export default class CodeforcesProvider implements IBasicProvider {
if (!this.account.handle) return false; if (!this.account.handle) return false;
const [csrf, ftaa, bfaa] = await this.getCsrfToken('/enter'); const [csrf, ftaa, bfaa, header] = await this.getCsrfToken('/enter');
const { header } = await this.get('/enter');
if (header['set-cookie']) { if (header['set-cookie']) {
this.cookie = header['set-cookie']; this.cookie = header['set-cookie'];