Project

twilioauth

0.0
No commit activity in last 3 years
No release in over 3 years
2 factor auth for twilio
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

About

Simple 2 factor authentication with Twilio sms.

Usage

require "twilioauth"
pin = Twilioauth.auth("+15555555555", :account_sid => "*************", :auth_token => "****************")

Simple example with controller methods.

def login
  #login has succeeded and now need to check pin
  session[:pin] = Twilioauth.auth(@user.phone, :account_sid => "**********", :auth_token => "**********")
  session[:pendinguser] = {name: params[:name], password: params[:password]}
  redirect_to "/auth"
end

def auth
  #form to enter pin here and submits to check_auth
  unless session[:pendinguser]
    redirect_to "/login"
  end
end

def check_auth
  #if the pin is the same set the user session
  if params[:pin] == session[:pin]
    session[:user] = session[:pendinguser]
    redirect_to "/success"
  else
    redirect_to "/login?pin_failed=true"
  end
end

TODO

Roll twilioauth into a rails engine with controllers and forms to handle everything for the developer.

History

0.0.5 removed a lot of unnecessary random charcter code.

0.0.4 first working version for rails integration

0.0.1 first working sms auth.