diff --git a/indexes.yaml b/indexes.yaml index e6622fe1..c57a9c18 100644 --- a/indexes.yaml +++ b/indexes.yaml @@ -134,26 +134,20 @@ indexes: - collection: authlog type: users # index applies to users database index: - name: user_action + name: user_by_ip key: user: 1 - action: 1 + ip: 1 # List events for user by IP _id: -1 - -- collection: authlog - type: users # index applies to users database - index: - name: by_session - key: - session: 1 - sparse: true + partialFilterExpression: + ip: true - collection: authlog type: users # index applies to users database index: name: by_ip key: - ip: 1 + ip: 1 # All events from this IP sparse: true - collection: authlog diff --git a/lib/api/auth.js b/lib/api/auth.js index e28fc74f..27668689 100644 --- a/lib/api/auth.js +++ b/lib/api/auth.js @@ -230,10 +230,6 @@ module.exports = (db, server, userHandler) => { .lowercase() .empty('') .max(100), - sess: Joi.string() - .trim() - .empty('') - .max(100), ip: Joi.string().ip({ version: ['ipv4', 'ipv6'], cidr: 'forbidden' @@ -273,9 +269,10 @@ module.exports = (db, server, userHandler) => { let user = new ObjectID(result.value.user); let limit = result.value.limit; + let action = result.value.action; - let sess = result.value.sess; let ip = result.value.ip; + let page = result.value.page; let pageNext = result.value.next; let pagePrevious = result.value.previous; @@ -309,12 +306,6 @@ module.exports = (db, server, userHandler) => { } let filter = { user }; - if (action) { - filter.action = action; - } - if (sess) { - filter.sess = sess; - } if (ip) { filter.ip = ip; }