Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
protection.js
readme.md

readme.md

Simple protection for e.g. Login forms.

  • download and copy ddos.js into the /modules/ directory or create a definition with:
var options = {};

// Timeout for an one attempt
// options.timeout = 3;

// Default maximum attempts
// options.max = 5;

INSTALL('module', 'https://modules.totaljs.com/latest/protection.js', options);
// UNINSTALL('module', 'protection');

Instance

var protection = MODULE('protection');

Protection.can(name, [max])

// protection.can(name, [max])
if (!protection.can(controller.ip))
   return controller.throw400('Protection for login form.');

// or
if (!protection.can(controller.ip, 3))
   return controller.throw400('Protection for login form.');

// or
if (!protection.can(controller.body.email))
   return controller.throw400('Protection for login form.');

Protection.reset([name])

if (!protection.can(controller.ip))
   return controller.throw400('Protection for login form.');

// resets protection
protection.reset(controller.ip);

// or resets all protection records
protection.reset();