Giter Site home page Giter Site logo

uuushiro / devise_sms_confirmable Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 5.0 3.12 MB

Module provide sms confirmation.You can handle SMS Message template as Devise handles ActionMailer template.

License: MIT License

Ruby 90.37% Shell 0.14% HTML 7.50% JavaScript 1.23% CSS 0.76%
sms ruby gem devise rails rails5

devise_sms_confirmable's Introduction

DeviseSmsConfirmable

DeviseSmsConfirmable is a module provide SMS confirmation. The user will receive an SMS with a token that can be entered on the site to activate the account. You can handle SMS's Message template as Devise handles ActionMailer's template.

Installation

Installation for Rails ~> 5.1.4 and Devise ~> 4.6.2 Add this line to your application's Gemfile (and Devise and TwilioRuby if you weren't using them):

gem 'devise'
gem 'devise_sms_confirmable'
gem 'twilio-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install devise_sms_confirmable

Usage

To use it, simply specify your DeviseSmsConfirmable configuration in config/initializers/devise.rb:

# Load the module for SMS confirmation
require 'devise_sms_confirmable'
# Default source phone number
config.sms_sender = 'some_e164_phone_number'

Configuring Models

Add :sms_confirmable option to The Devise method in your models.

devise :database_authenticatable, :sms_confirmable

Add columns to model

t.string   :phone,              null: false, default: ""
t.string   :sms_confirmation_token
t.datetime :sms_confirmed_at
t.datetime :sms_confirmation_sent_at
# t.string   :unconfirmed_phone # Only if using reconfirmable

Allow models to sign in using their phone number

config.authentication_keys = [:phone]

Configuring twilio-ruby

config/initializers/twilio.rb

Choosing and chaining delivery methods

devise_sms_confirmable use textris for the delivery system. See textris for details. The following is a sample (quoted from textris) using twilio.

# Send messages via the Twilio REST API
config.textris_delivery_method = :twilio

# Don't send anything, log messages into Rails logger
config.textris_delivery_method = :log

# Don't send anything, access your messages via Textris::Base.deliveries
config.textris_delivery_method = :test

Twilio

textris connects with the Twilio API using twilio-ruby gem. It does not, however, install the gem for you. If you don't have it yet, add the twilio-ruby gem to Gemfile:

gem 'twilio-ruby'

Then, pre-configure the twilio-ruby settings by creating the config/initializers/twilio.rb file:

Twilio.configure do |config|
  config.account_sid = 'some_sid'
  config.auth_token  = 'some_auth_token'
end

To use Twilio's Copilot use twilio_messaging_service_sid in place of from when sending a text or setting defaults.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/devise_sms_confirmable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the DeviseSmsConfirmable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

devise_sms_confirmable's People

Contributors

dependabot[bot] avatar tsuda-kyosuke avatar uuushiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

devise_sms_confirmable's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.