Skip to content

Commit

Permalink
fix(remote_judger/atcoder): add referer when submitting problem
Browse files Browse the repository at this point in the history
  • Loading branch information
renbaoshuo committed Jul 18, 2024
1 parent 70d5b54 commit afda929
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions remote_judger/src/providers/atcoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -208,12 +207,14 @@ 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,
'data.TaskScreenName': problemId,
'data.LanguageId': programType.id,
sourceCode: code,
});
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) {
await end({
Expand All @@ -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'];
Expand Down

0 comments on commit afda929

Please sign in to comment.