Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/hydrojudge/src/hosts/hydro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ export default class Hydro implements Session {
async login() {
log.info('[%s] Updating session', this.config.host);
const res = await this.post('login', {
uname: this.config.uname, password: this.config.password, rememberme: 'on',
uname: this.config.uname, password: this.config.password,
rememberme: 'on', judge: 'on',
});
const setCookie = res.headers['set-cookie'];
await this.setCookie(Array.isArray(setCookie) ? setCookie.join(';') : setCookie);
Expand Down
6 changes: 4 additions & 2 deletions packages/hydrooj/src/handler/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ class UserLoginHandler extends Handler {
@param('redirect', Types.String, true)
@param('tfa', Types.String, true)
@param('authnChallenge', Types.String, true)
@param('judge', Types.Boolean, true)
async post(
domainId: string, uname: string, password: string, rememberme = false, redirect = '',
tfa = '', authnChallenge = '',
tfa = '', authnChallenge = '', judge = false,
) {
if (!system.get('server.login')) throw new BuiltinLoginError();
if (!judge && !system.get('server.login')) throw new BuiltinLoginError();
let udoc = await user.getByEmail(domainId, uname);
udoc ||= await user.getByUname(domainId, uname);
if (judge && !system.get('server.login') && !udoc?.hasPriv(PRIV.PRIV_JUDGE)) throw new BuiltinLoginError();
if (!udoc) throw new UserNotFoundError(uname);
if (system.get('system.contestmode') && !udoc.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
if (udoc._loginip && udoc._loginip !== this.request.ip) throw new ValidationError('ip');
Expand Down
Loading