Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple captcha for Node.JS and Express (or Connect).
JavaScript
branch: master

Merge pull request #5 from xhochy/patch-1

Use req.path instead of req.url to add cachebreaker URL-Parameters
latest commit faa8109af1
@napa3um authored
Failed to load latest commit information.
.gitignore gitignore
History.md usage doc
LICENSE first commit
Readme.md usage doc
captcha.js Use req.path instead of req.url to add cachebreaker URL-Parameters
package.json usage doc

Readme.md

Captcha

Simple captcha for Connect/Express.

Installation

Via npm:

$ npm install captcha

Usage (for Express 3)

var express = require('express');
var captcha = require('captcha');

var app = express();

app.configure(function(){
    app.use(express.bodyParser());
    app.use(express.cookieParser());
    app.use(express.cookieSession({ secret: 'keyboard-cat' }));
    app.use(captcha({ url: '/captcha.jpg', color:'#0064cd', background: 'rgb(20,30,200)' })); // captcha params
});

app.get('/', function(req, res){
    res.type('html');
    res.end('<img src="/captcha.jpg"/><form action="/login" method="post"><input type="text" name="digits"/></form>'); // captcha render
});

app.post('/login', function(req, res){
    res.type('html');
    res.end('CONFIRM: ' + (req.body.digits == req.session.captcha)); // captcha verify
});

app.listen(8080);
console.log('Web server started.');
Something went wrong with that request. Please try again.