plugins: changed parameters of event attemptingLogin
Massimo Melina committed
Sep 3, 2024 at 10:30 UTC
651c65cb1c0e19d823c6d19a24d51ea8773a11c7
4 files changed
+4
-4
plugins/antibrute/plugin.js
+1
-1
@@ -19,7 +19,7 @@ exports.init = api => {
19
const { block } = api.require('./block')
20
return {
21
unload: api.events.multi({
22
- attemptingLogin: async ctx => {
22
+ attemptingLogin: async ctx => {
23
const { ip } = ctx
24
const now = new Date
25
const rec = getOrSet(byIp, ip, () => ({ attempts: 0, next: now }))
src/api.auth.ts
+1
-1
@@ -19,7 +19,7 @@ export const loginSrp1: ApiHandler = async ({ username }, ctx) => {
19
const account = getAccount(username)
20
if (!ctx.session)
21
return new ApiError(HTTP_SERVER_ERROR)
22
- await events.emitAsync('attemptingLogin', ctx)
22
+ await events.emitAsync('attemptingLogin', { ctx, username })
23
if (!account || !accountCanLogin(account)) { // TODO simulate fake account to prevent knowing valid usernames
24
ctx.logExtra({ u: username })
25
ctx.state.dontLog = false // log even if log_api is false
src/const.ts
+1
-1
@@ -7,7 +7,7 @@ import { mkdirSync } from 'fs'
7
import { basename, dirname, join } from 'path'
8
export * from './cross-const'
9
10
-export const API_VERSION = 9
10
+export const API_VERSION = 9.1
11
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
12
export const HFS_REPO = 'rejetto/hfs'
13
src/middlewares.ts
+1
-1
@@ -127,7 +127,7 @@ export const prepareState: Koa.Middleware = async (ctx, next) => {
127
128
async function doLogin(u: string, p: string) {
129
if (!u || u === ctx.session?.username) return // providing credentials, but not needed
130
- await events.emitAsync('attemptingLogin', ctx)
130
+ await events.emitAsync('attemptingLogin', { ctx, username: u })
131
const a = await srpCheck(u, p)
132
if (a) {
133
await setLoggedIn(ctx, a.username)