JCore Authentication Logger - Track and manage login attempts with database logging
npm install @kiattiwong-jdea/jauthenlogAuthentication Logger - Track and manage login attempts with database logging
``bash`
npm install @kiattiwong-jdea/jauthenlog
``
AUTHENLOG_DB_HOST=localhost
AUTHENLOG_DB_PORT=3306
AUTHENLOG_DB_USERNAME=root
AUTHENLOG_DB_PASSWORD=password
AUTHENLOG_DB_NAME=your_database
`typescript
import { Authen, DBTYPE, ATTEMPT_UNIT_CONDITION } from '@kiattiwong-jdea/jauthenlog';
const authen = new Authen({
dbType: DBTYPE.MYSQL,
limitFailed: 5,
attemptAmount: 15,
attemptUnit: ATTEMPT_UNIT_CONDITION.MINUTE
});
// Validate login attempt
const result = await authen.ValidateAuthAttempt({
username: 'user@example.com',
ipAddress: '192.168.1.1'
});
// Clear authentication log on successful login
await authen.ClearAuthenLog({
username: 'user@example.com',
ipAddress: '192.168.1.1'
});
``
MIT