mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix judger login if builtin login disabled (#1155)
This commit is contained in:
1 parent
e3fa08f56c
commit
843828089e
2 files changed
+6
-3
No files matched your search
@@ -221,7 +221,8 @@ export default class Hydro implements Session {
|
|||||||
async login() {
|
async login() {
|
||||||
log.info('[%s] Updating session', this.config.host);
|
log.info('[%s] Updating session', this.config.host);
|
||||||
const res = await this.post('login', {
|
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'];
|
const setCookie = res.headers['set-cookie'];
|
||||||
await this.setCookie(Array.isArray(setCookie) ? setCookie.join(';') : setCookie);
|
await this.setCookie(Array.isArray(setCookie) ? setCookie.join(';') : setCookie);
|
||||||
|
|||||||
@@ -57,13 +57,15 @@ class UserLoginHandler extends Handler {
|
|||||||
@param('redirect', Types.String, true)
|
@param('redirect', Types.String, true)
|
||||||
@param('tfa', Types.String, true)
|
@param('tfa', Types.String, true)
|
||||||
@param('authnChallenge', Types.String, true)
|
@param('authnChallenge', Types.String, true)
|
||||||
|
@param('judge', Types.Boolean, true)
|
||||||
async post(
|
async post(
|
||||||
domainId: string, uname: string, password: string, rememberme = false, redirect = '',
|
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);
|
let udoc = await user.getByEmail(domainId, uname);
|
||||||
udoc ||= await user.getByUname(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 (!udoc) throw new UserNotFoundError(uname);
|
||||||
if (system.get('system.contestmode') && !udoc.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
|
if (system.get('system.contestmode') && !udoc.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
|
||||||
if (udoc._loginip && udoc._loginip !== this.request.ip) throw new ValidationError('ip');
|
if (udoc._loginip && udoc._loginip !== this.request.ip) throw new ValidationError('ip');
|
||||||
|
|||||||
Reference in new issue
Block a user