Closed rvfx closed 2 years ago
Good point! I normally use this with the Authy App, so I don't notice that it doesn't send an SMS immediately.
We can add that as a setting, if that's something you would be interested in?
Otherwise, you can add it yourself by overriding the DeviseAuthyController
like so:
# app/controllers/devise_authy_controller.rb
class DeviseAuthyController < Devise::DeviseAuthyController
before_action :send_request, :only => :GET_verify_authy
private
def send_request
Authy::API.request_sms(:id => @resource.authy_id)
end
end
Then override the route too:
# config/routes.rb
Rails.application.routes.draw do
devise_for :users, :controllers => { :devise_authy => :devise_authy }
# other routes
end
Note that the request_sms
route sends :force => true
so that it sends an SMS even if the user normally uses the app. In the code above, it just makes a regular request which will send a push notification to the Authy app if the user uses that.
One thing I'm not sure about right now is what happens in the case where you use a third party authenticator. It may cause SMS messages to be sent, even if the user could just open their authenticator app. That would likely be worth testing.
Thank you, this works great! I think the setting would be a valuable addition, as many users know the process this way from websites like Paypal.
This library is no longer actively maintained. The Authy API has been replaced with the Twilio Verify API. Twilio will support the Authy API through November 1, 2022 for SMS/Voice. After this date, we’ll start to deprecate the service for SMS/Voice. Any requests sent to the API after May 1, 2023, will automatically receive an error. Push and TOTP will continue to be supported through July 2023.
Learn more about migrating from Authy to Verify.
Please visit the Twilio Docs for:
Please direct any questions to Twilio Support. Thank you!
My problem is pretty much what the title says. Everything works fine, but I have to click the "request sms" link manually every time, otherwise no sms is sent. Is this a bug or a feature?