Skip to content

Commit 8438280

Browse files
authored
core: fix judger login if builtin login disabled (#1155)
1 parent e3fa08f commit 8438280

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/hydrojudge/src/hosts/hydro.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ export default class Hydro implements Session {
221221
async login() {
222222
log.info('[%s] Updating session', this.config.host);
223223
const res = await this.post('login', {
224-
uname: this.config.uname, password: this.config.password, rememberme: 'on',
224+
uname: this.config.uname, password: this.config.password,
225+
rememberme: 'on', judge: 'on',
225226
});
226227
const setCookie = res.headers['set-cookie'];
227228
await this.setCookie(Array.isArray(setCookie) ? setCookie.join(';') : setCookie);

packages/hydrooj/src/handler/user.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ class UserLoginHandler extends Handler {
5757
@param('redirect', Types.String, true)
5858
@param('tfa', Types.String, true)
5959
@param('authnChallenge', Types.String, true)
60+
@param('judge', Types.Boolean, true)
6061
async post(
6162
domainId: string, uname: string, password: string, rememberme = false, redirect = '',
62-
tfa = '', authnChallenge = '',
63+
tfa = '', authnChallenge = '', judge = false,
6364
) {
64-
if (!system.get('server.login')) throw new BuiltinLoginError();
65+
if (!judge && !system.get('server.login')) throw new BuiltinLoginError();
6566
let udoc = await user.getByEmail(domainId, uname);
6667
udoc ||= await user.getByUname(domainId, uname);
68+
if (judge && !system.get('server.login') && !udoc?.hasPriv(PRIV.PRIV_JUDGE)) throw new BuiltinLoginError();
6769
if (!udoc) throw new UserNotFoundError(uname);
6870
if (system.get('system.contestmode') && !udoc.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
6971
if (udoc._loginip && udoc._loginip !== this.request.ip) throw new ValidationError('ip');

0 commit comments

Comments
 (0)