UNPKG

@experium/nest-bruteforce-guard

Version:
28 lines (27 loc) 838 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractExceptionCatcher = void 0; class AbstractExceptionCatcher { constructor(registry, config) { registry.register(this); this.config = config; } handle(exception, context) { if (this.supports(exception)) { return this.catch(exception, context); } } getPayloadByContext(context) { const login = this.getLoginByContext(context); const ip = context.switchToHttp().getRequest().ip; return { ip, login, }; } getLoginByContext(context) { const loginField = this.config.loginField; return context.switchToHttp().getRequest().body[loginField]; } } exports.AbstractExceptionCatcher = AbstractExceptionCatcher;