Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phone number based Devise authentication for mobile apps [closed]

We all know that Devise is de facto standard for implementing authentication on rails based apps.

By default it uses email as ID but also allows you to use usernames instead. It also has "Confirmable" module which lets you confirm the email address by sending an email and clicking through the link to verify your email.

I was looking for something similar for phone numbers--basically accepting phone numbers as primary ID instead of emails, and then confirm the phone number by sending an auth code as SMS message to the user's number via something like Twilio, and then let the user confirm it by entering the code (or even let the user click through a generated link to verify just like they do with emails)

The reason I was expecting there to be a popular devise module for this functionality was because it seems as if most mobile social apps accept phone numbers and confirm the number nowadays. There's gotta be someone who thought this was a problem and open-sourced a module for this. However I couldn't find any popular ones. Actually to be precise, here are the only three relevant links I've found on this:

  • https://github.com/giano/devise_sms_activable
  • https://github.com/baranov-sv/devise_sms_confirmable
  • Rails register User using phone number and confirmation

None of them leads to a working solution (I've tried devise_sms_activable but it doesn't work for rails 4, plus I'm wary of the low number of stars) So I wanted to ask if there's any viable solution to this. Am I missing something? Has this topic been brought up among the Devise developer community? I'm curious about the solution but if there is none, I would at least appreciate any answer on why this is not readily available.

[UPDATE]

I think the question might have been a bit misleading. While I can just build it myself, I don't like to re-invent the wheel. Basically my intention with this question was:

  1. If there's any package that does this (like all the modules such as confirmable, token_authentcatable, etc. Maybe not even a Devise module and it could be entirely a different thing)
  2. Or, if there is no such pre-built solution, why there isn't one. I just can't comprehend why there is no such solution I can find when everyone seems to be doing this.

I will gladly accept when I get an answer to either #1 or #2. Thanks!

like image 259
Vlad Avatar asked Mar 20 '14 01:03

Vlad


1 Answers

i've looked into that before... but the project requirements changed... so all of the following are relative links found on the devise wiki

  • this how to allows you to sign in and authenticate with different fields other than the email address
  • A Simple Token Authentication Service for Mobile Devices Using Rails 3 and Devise.

you can use the previous tuts in conjunction with some thing like Twilio to send the created custom auth token and authenticate user with phone number other than email.

[UPDATE]

since you mentioned an already working solution, I think this is what you are looking for. Active Model OTP and this blog post it's new and i didn't have the chance to test drive it :D

I also found Two factor authentication Devise extension

[UPDATE Aug/2017]

Based on a project that I was recently working on, I found that Tinfoil/devise-two-factor provides a really good/extensible integration with devise (and is highly customizable)... using the internal ROTP gem, you can provide different length codes based on different authentication methods (APP/SMS) and different window/drift allowed per method without having to write the whole thing from the ground up. (highly recommended if you want full power over complex workflow)

like image 119
a14m Avatar answered Oct 03 '22 10:10

a14m