mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: limits: allow by-user
This commit is contained in:
1 parent
f65aba6d27
commit
273a0563b3
5 files changed
+10
-9
No files matched your search
@@ -287,7 +287,7 @@ export class ContestScoreboardHandler extends ContestDetailBaseHandler {
|
||||
}
|
||||
|
||||
async exportScoreboard(domainId: string, tid: ObjectID, ext: string) {
|
||||
await this.limitRate('scoreboard_download', 120, 3);
|
||||
await this.limitRate('scoreboard_download', 60, 3);
|
||||
if (ext === 'ghost') {
|
||||
await this.exportGhost(domainId, tid);
|
||||
return;
|
||||
@@ -415,7 +415,7 @@ export class ContestCodeHandler extends Handler {
|
||||
@param('tid', Types.ObjectID)
|
||||
@param('all', Types.Boolean)
|
||||
async get(domainId: string, tid: ObjectID, all: boolean) {
|
||||
await this.limitRate('contest_code', 3600, 60);
|
||||
await this.limitRate('contest_code', 60, 10);
|
||||
const [tdoc, tsdocs] = await contest.getAndListStatus(domainId, tid);
|
||||
if (!this.user.own(tdoc) && !this.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE)) {
|
||||
this.checkPerm(PERM.PERM_READ_RECORD_CODE);
|
||||
|
||||
@@ -525,7 +525,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
}
|
||||
}
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission_user'), true);
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission'), false);
|
||||
const files: Record<string, string> = {};
|
||||
if (!code) {
|
||||
const file = this.request.files?.file;
|
||||
@@ -599,7 +599,7 @@ export class ProblemHackHandler extends ProblemDetailHandler {
|
||||
@param('tid', Types.ObjectID, true)
|
||||
async post(domainId: string, input = '', tid?: ObjectID) {
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission_user'), true);
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
||||
await this.limitRate('add_record', 60, system.get('limit.submission'), false);
|
||||
const id = `${this.user._id}/${nanoid()}`;
|
||||
if (this.request.files?.file?.size > 0) {
|
||||
const file = this.request.files.file;
|
||||
|
||||
@@ -121,8 +121,8 @@ class UserLoginHandler extends Handler {
|
||||
if (!udoc) udoc = await user.getByUname(domainId, uname);
|
||||
if (!udoc) throw new UserNotFoundError(uname);
|
||||
await Promise.all([
|
||||
this.limitRate('user_login', 60, 30),
|
||||
this.limitRate(`user_login_${uname}`, 60, 5),
|
||||
this.limitRate('user_login', 60, 30, false),
|
||||
this.limitRate(`user_login_${uname}`, 60, 5, false),
|
||||
oplog.log(this, 'user.login', { redirect }),
|
||||
]);
|
||||
if (udoc._tfa && !verifyToken(udoc._tfa, tfa)) throw new InvalidTokenError('2FA token invalid.');
|
||||
@@ -199,7 +199,7 @@ export class UserRegisterHandler extends Handler {
|
||||
const mailDomain = mail.split('@')[1];
|
||||
if (await BlackListModel.get(`mail::${mailDomain}`)) throw new BlacklistedError(mailDomain);
|
||||
await Promise.all([
|
||||
this.limitRate('send_mail', 3600, 30),
|
||||
this.limitRate('send_mail', 3600, 30, false),
|
||||
oplog.log(this, 'user.register', {}),
|
||||
]);
|
||||
const t = await token.add(
|
||||
|
||||
Reference in new issue
Block a user