fix(remote_judger/atcoder): add referer when submitting problem

This commit is contained in:
Baoshuo Ren 2024-07-18 15:51:35 +08:00
parent 70d5b541de
commit afda9290fa
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -193,9 +193,8 @@ export default class AtcoderProvider implements IBasicProvider {
}
const [contestId, problemId] = parseProblemId(id);
const csrf = await this.getCsrfToken(
`/contests/${contestId}/tasks/${problemId}`
);
const referer = `/contests/${contestId}/tasks/${problemId}`;
const csrf = await this.getCsrfToken(referer);
logger.debug(
'Submitting',
@ -208,11 +207,13 @@ export default class AtcoderProvider implements IBasicProvider {
await next({ status: 'Submitting to AtCoder...' });
// TODO: check submit time to ensure submission
const res = await this.post(`/contests/${contestId}/submit`).send({
csrf_token: csrf,
const res = await this.post(`/contests/${contestId}/submit`)
.set('Referer', referer)
.send({
'data.TaskScreenName': problemId,
'data.LanguageId': programType.id,
sourceCode: code,
csrf_token: csrf,
});
if (res.error) {
@ -233,7 +234,9 @@ export default class AtcoderProvider implements IBasicProvider {
const { text: status, header: status_header } = await this.get(
`/contests/${contestId}/submissions/me`
).retry(3);
)
.set('Referer', referer)
.retry(3);
if (status_header['set-cookie']) {
this.cookie = status_header['set-cookie'];