Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis_captcha

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis_captcha

  • 0.8.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RedisCaptcha

RedisCaptcha is a captcha engine base on Redis for Rails 3.2. It provides simple captcha that can be read by human.

Features

  • RedisCaptcha is easy to setup, easy to use.
  • RedisCaptcha provides simple captcha that can be read by human.
  • You don't have to manage image files because they will be removed by Tempfile.
  • You can set option locked_times and locked_time to avoid someone who want to attack.
  • The Captcha will be Expired automatically by setting expired_time.
  • ......

Requirements

  • Ruby >= 1.9
  • Rails > 3.2
  • Redis > 2.4
  • ImageMagick

I haven't tried lower version yet.

Getting started

1. Add RedisCaptcha to your gemfile

gem 'redis_captcha'

2. Generate initializer

rails g redis_captcha:install

It'll generate config/initializers/redis_captcha.rb, and you can configure all options here.

3. Mount RedisCaptcha::Engine in your router.rb

mount RedisCaptcha::Engine => '/captcha', :as => :captcha

4. Add before_filter to your controller

class PostsController < ApplicationController
    before_filter :generate_captcha_key, :only => [:new, :edit]
    ......
end

4. Add module to your model

class Post < ActiveRecord::Base
    include RedisCaptcha::Model
end

if you set config.active_record.whitelist_attributes = true in config/application.rb, remember to add attr_accessible to your model:

attr_accessible :captcha, :captcha_key

to your model.

5. Use RedisCaptcha in your view

<%= image_tag(captcha_path(:timestamp => Time.now.to_i), :alt => "captcha") %>
<%= f.text_field :captcha %>
<%= f.hidden_field :captcha_key, :value => session[:captcha_key] %>

6. Use RedisCaptcha in your controller

    # Initialize a post
    @post = Post.new(:title => "test")

    # valid with captcha
    @post.valid?

    # save with captcha
    @post.save

    # valid without captcha
    @post.valid_without_captcha?

    # save without captcha
    @post.save_without_captcha

Enjoy it!

Todo list

  • To add a simple site
  • To write tests

History

0.8.0

First Version

Author

  • I'm hellolucky, I come from Taiwan
  • hellolucky123@gmail.com
  • http://twitter.com/hellolucky123
  • http://blog.hellolucky.info

License

This project rocks and uses MIT-LICENSE.

FAQs

Package last updated on 31 Oct 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc