DeviseSmsVerifiable
This gem is no longer maintained!
Just a simple module for Devise to provide sms functions, easy to use and customize.
This is the working version.
# Developed and tested on:
Ruby 2.1.0
Rails 4.0.3
Devise 3.2
Getting started
-
Add to
Gemfile
andbundle install
.gem 'devise_sms_verifiable'
-
If Devise is installed, run the generator to add configuration settings to Devise initializer:
$ rails generate devise_sms_verifiable:install
Otherwise use this generator:
$ rails generate devise:install
-
Generate migration:
$ rails generate devise_sms_verifiable:migration
And run
rake db:migrate
. Migration will add several fields to model:< User id: 1, email: "shindu666<bla>gmail.com", created_at: "2014-03-25 15:24:30", updated_at: "2014-03-25 15:26:44", phone: "+79818327398", <----------| phone field sms_answer: 1245, <----------| answer field phone_confirm: false > <----------| need confirmation?
-
Configure model
class User < ActiveRecord::Base devise :database_authenticatable, :registerable, ... :sms_verifiable, ... :recoverable end
That's it. You got your module working.
Helpers
Now you have few helpers in model:
=> user = User.find(23)
=> user.sms_confirm?
#> true
=> user.sms_unconfirm!
#> true
=> user.sms_confirm!
#> true
Configure module
This module is very customizable, check it out:
-
Generate views
$ rails generate devise_sms_verifiable:views
2. Boolean field in model for phone confirmation
```ruby
config.phone_confirmation_field = :phone_confirm
-
Field returning the correct answer
config.sms_answer_field = :sms_answer
-
Field with phone number
config.phone_field = :phone
-
Path after successful confirmation
config.successful_path = '/'
-
SMS provider module
There is a default module for STREAM-TELECOM, but you can define your own.
## You can define other provider module. ## It should have a method :send_sms with 2 args ## e.g.: ## YourAwesomeProvider.send_sms(number_phone, message) config.sms_provider = YourAwesomeProvider
-
Token generator method(default 4 digit)
config.token_generator = -> { rand(10..20) }
Configure default provider
-
Send sms silently for test
config.provider_silent = true
-
SMS provider login
config.provider_login = 'provider_login'
-
SMS provider password
config.provider_password = 'provider_password'
-
SMS provider 'from' field
config.provider_from = 'provider_from'
TODO
- Add helper methods to controller
Kiselenko Roman 2014-03-16
This project rocks and uses MIT-LICENSE.