Module: DeviseGoogleAuthenticator::Controllers::Helpers
- Defined in:
- lib/devise_google_authenticatable/controllers/helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#google_authenticator_qrcode(user) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/devise_google_authenticatable/controllers/helpers.rb', line 4 def google_authenticator_qrcode(user) data = "otpauth://totp/#{username_from_email(user.email)}@#{Rails.application.class.parent_name}?secret=#{user.gauth_secret}" data = Rack::Utils.escape(data) url = "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=#{data}" return image_tag(url, :alt => 'Google Authenticator QRCode') end |
#username_from_email(email) ⇒ Object
11 12 13 |
# File 'lib/devise_google_authenticatable/controllers/helpers.rb', line 11 def username_from_email(email) (/^(.*)@/).match(email)[1] end |