This module is concerned with the generation of secure forms and validation of data collected by forms
require('../security.json')
Module Instantiation
method name | description | params | returns |
---|---|---|---|
N/A | returns values for autocomplete, method and _csrf token | request, response Http, callback function | form configurations or Error |
USAGE
// where security = require('security')
app.get('/next', function (request, response, next) {
let form = security.forms
form(request, response, function (err) {
if (err) {
next(err)
} else {
response.send(`<form action='/next' method="${security.forms.method}
autocomplete=${security.forms.autocomplete}
<div> <label for="email">Email</label>
<input id="email" name="email" type="text" /></div>
<div> <label for="password">Password</label>
<input id="password" name="password" type="password" /></div>
<input type="submit" value="Submit" />
<input type="hidden" name="_csrf" value="${security.forms._csrf}" />
</form>`)
}
})
})
...
formProtection.enabled = true
in security.json