giano / devise_sms_activable

A snap-in to Devise to allow user activation via SMS token
MIT License
65 stars 75 forks source link

= devise_sms_activable

Devise Sms Activable is a snap-in for Devise that will make any resource activable via SMS. The user will receive an SMS with a token that can be entered on the site to activate the account. Ask the user his phone (and phone confirmation to double check) on registration and the token will be sended automagically.

== Installation for Rails ~> 3.0 and Devise ~> 1.1

Install DeviseSmsActivable gem, it will also install dependencies (such as devise and warden):

gem install devise_sms_activable

Add DeviseSmsActivable to your Gemfile (and Devise if you weren't using them):

gem 'devise', '>= 1.1.0' gem 'devise_sms_activable', '~> 0.0.9'

=== Automatic installation

Run the following generator to add DeviseSmsActivable’s configuration option in the Devise configuration file (config/initializers/devise.rb) and the sms sender class in your lib folder:

rails generate devise_sms_activable:install

When you are done, you are ready to add DeviseSmsActivable to any of your Devise models using the following generator:

rails generate devise_sms_activable MODEL

Replace MODEL by the class name you want to add DeviseSmsActivable, like User, Admin, etc. This will add the :sms_activable flag to your model's Devise modules. The generator will also create a migration file (if your ORM support them). Continue reading this file to understand exactly what the generator produces and how to use it.

== Configuring views

All the views are packaged inside the gem. If you'd like to customize the views, invoke the following generator and it will copy all the views to your application:

rails generate devise_sms_activable:views

You can also use the generator to generate scoped views:

rails generate devise_sms_activable:views users

Please refer to {Devise's README}[http://github.com/plataformatec/devise] for more information about views.

== Usage

The model is specular to the Devise's own Confirmable model. It only requires the user to supply a valid phone number.

On registration it will send an SMS with a token to be inserted to complete activation process. By default users MUST activate by SMS before entering. If you want something more "relaxed" just override sms_confirmation_required? in your model and make it your way. You can use the convenience filter require_sms_activated! in your controller to block sms-unactive users from specific pages.

== Controller filter

DeviseSmsActivable extends your controllers with a require_sms_activated! method. Use it to restrict part of the site to "confirmed users" only

== I18n

DeviseSmsActivable installs a localizable file in your config/locales folder.

== Contributing to devise_sms_activable

== Copyright

Copyright (c) 2011 Stefano Valicchia. See LICENSE.txt for further details.