Repository is archived
No commit activity in last 3 years
No release in over 3 years
Module provide sms functions, easy to use and customize.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

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

  1. Add to Gemfile and bundle install.

    gem 'devise_sms_verifiable'
  2. 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
    
  3. 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?
  4. 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:

  1. Generate views

    $ rails generate devise_sms_verifiable:views
    
2. Boolean field in model for phone confirmation

 ```ruby
 config.phone_confirmation_field = :phone_confirm
  1. Field returning the correct answer

    config.sms_answer_field = :sms_answer
  2. Field with phone number

    config.phone_field = :phone
  3. Path after successful confirmation

    config.successful_path = '/'
  4. 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
  5. Token generator method(default 4 digit)

    config.token_generator = -> { rand(10..20) }

Configure default provider

  1. Send sms silently for test

    config.provider_silent = true
  2. SMS provider login

    config.provider_login = 'provider_login'
  3. SMS provider password

    config.provider_password = 'provider_password'
  4. SMS provider 'from' field

    config.provider_from = 'provider_from'

TODO

  1. Add helper methods to controller

Kiselenko Roman 2014-03-16

This project rocks and uses MIT-LICENSE.