Need help with node-captcha?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

napa3um
130 Stars 45 Forks MIT License 36 Commits 4 Opened issues

Description

Simple captcha for Node.JS and Express.

Services available

!
?

Need anything else?

Contributors list

# 310,013
CSS
koajs
JavaScr...
Nuxt.js
22 commits
# 295,182
PHP
Shell
C++
captcha
5 commits
# 95,708
Node.js
GraphQL
webpack...
Electro...
2 commits
# 22,738
parquet
arrow
pandas
scikit-...
1 commit

Captcha

Simple captcha for Express.

WARNING! New API (0.0.5 -> 0.1.0)

Installation

Via npm:

$ npm install captcha

Usage (for Express 4)

'use strict'

const express = require('express') const session = require('express-session') const bodyParser = require('body-parser')

const captchaUrl = '/captcha.jpg' const captchaId = 'captcha' const captchaFieldName = 'captcha'

const captcha = require('./captcha').create({ cookie: captchaId })

const app = express() app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: true, })) app.use(bodyParser.urlencoded({ extended: false }))

app.get(captchaUrl, captcha.image())

app.get('/', (req, res) => { res.type('html') res.end( <img src="%24%7B%20captchaUrl%20%7D"> </pre><form action="/login" method="post"> <input type="text" name="${ captchaFieldName }"> <input type="submit"> </form> ) })

app.post('/login', (req, res) => { res.type('html') res.end( <p>CAPTCHA VALID: ${ captcha.check(req, req.body[captchaFieldName]) }</p> ) })

app.listen(8080, () => { console.log('server started') })

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.