lundi 12 octobre 2015

Send devise confirmation instructions using SMS or email

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.

Aucun commentaire:

Enregistrer un commentaire