5
votes

Hi I have used devise for the authentication purpose and also made few changes in it such I have provided sign in using both email and mobile number. Refereed this link.

Here is my code

def self.find_for_database_authentication(conditions={})
    find_by(mobile_number: conditions[:email]) || find_by(email: conditions[:email])
  end

I am using confirmable module for sending confirmation instructions and they are working fine for email.

Now if user doesn't enter this email (only enters the mobile number) then he has to send the SMS (Confirmation instruction in SMS).

So I have following doubts

  • How can I achieve this functionality?
  • How can I generate the same confirmation link for the same.

EDIT (I tried following solutions for generating confirmation link)

As I have to send the confirmation link in SMS also, so I tried to generate the given link using following

http://localhost:3000/admin_users/confirmation?confirmation_token=#{@user.confirmation_token}"

it generates the follwing type of link

http://localhost:3000/admin_users/confirmation?confirmation_token=00b2880c9662c65dc6d276db08532ea42d4333e6b7d2357d036cb9233eed41e8 

when I tired to use this link it gives me Confirmation token is invalid error. After searching I found this. So how can I generate the confirmation link out side the devise scope.

1

1 Answers

-1
votes

As for sending the instructions via SMS you might want to take a look at tropo service or restcomm if you want to setup your on server. Tropo is particularly easy to use, you will need a small deposit (like $10) to enable the SMS sending feature.

Regarding the generation of the url, you might have to create a controller that extends Devise::ConfirmationsController and override the create method to add the logic to check for the existence of email or phone number and react properly.