twilio / authy-devise

Authy Devise plugin to add Two-Factor Authentication
MIT License
200 stars 84 forks source link

Not enabling user for 2fa #77

Closed jonhue closed 6 years ago

jonhue commented 7 years ago

I am using Rails 5.1.

Whenever I enable a user for 2fa by submitting the related form on the enable_authy.html.haml template, It just refreshes the page.

Here are the logs:

Started GET "/2fa/enable" for 127.0.0.1 at 2017-06-10 17:33:01 +0200
Processing by Devise::DeviseAuthyController#GET_enable_authy as HTML
  Parameters: {"subdomain"=>""}
  User Load (0.5ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 6877909168363724625 ORDER BY `users`.`id` ASC LIMIT 1
  Rendering devise/devise_authy/enable_authy.html.haml within layouts/application
  Rendered shared/assets/icons/ui/_close.html (0.0ms) [cache miss]
  Rendered shared/components/_esc_close.html.haml (40.1ms) [cache miss]
  Rendered shared/assets/icons/loaders/_button.html (0.5ms) [cache miss]
  Rendered devise/devise_authy/enable_authy.html.haml within layouts/application (118.0ms)
  Rendered shared/assets/icons/loaders/_saving.html (0.5ms) [cache miss]
  Rendered shared/components/notifications/_notification.html.haml (42.0ms) [cache miss]
  Rendered shared/components/notifications/_notification.html.haml (4.5ms) [cache miss]
  Rendered shared/layouts/body/notifications/_notifications.html.haml (117.0ms) [cache miss]
  Rendering layouts/base.html.haml
  Rendered shared/layouts/head/analytics/_google_analytics.html.erb (0.5ms) [cache miss]
  Rendered shared/layouts/head/_schema_markup.html (0.5ms) [cache miss]
  Rendered layouts/base.html.haml (1319.1ms)
Completed 200 OK in 2021ms (Views: 2005.4ms | ActiveRecord: 1.5ms)

Started POST "/2fa/enable" for 127.0.0.1 at 2017-06-10 17:38:09 +0200
Processing by Devise::DeviseAuthyController#POST_enable_authy as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Y22fjdrfZyRrlBjj9eyN4Vyi1/HYJZjV8JowXAAeVVugF86fKdh26pWrawouBrH3V4e2CSx7RjNUB7XWk37PKQ==", "country"=>"United States", "country_code"=>"us", "cellphone"=>["1234567890"], "subdomain"=>""}
  User Load (0.5ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 6877909168363724625 ORDER BY `users`.`id` ASC LIMIT 1
Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.
  Rendering devise/devise_authy/enable_authy.html.haml within layouts/application
  Rendered shared/assets/icons/ui/_close.html (0.5ms) [cache miss]
  Rendered shared/components/_esc_close.html.haml (39.4ms) [cache miss]
  Rendered shared/assets/icons/loaders/_button.html (0.5ms) [cache miss]
  Rendered devise/devise_authy/enable_authy.html.haml within layouts/application (117.9ms)
  Rendered shared/assets/icons/loaders/_saving.html (0.5ms) [cache miss]
  Rendered shared/components/notifications/_notification.html.haml (41.0ms) [cache miss]
  Rendered shared/components/notifications/_notification.html.haml (4.5ms) [cache miss]
  Rendered shared/layouts/body/notifications/_notifications.html.haml (116.0ms) [cache miss]
  Rendering layouts/base.html.haml
  Rendered shared/layouts/head/analytics/_google_analytics.html.erb (0.5ms) [cache miss]
  Rendered shared/layouts/head/_schema_markup.html (0.5ms) [cache miss]
  Rendered layouts/base.html.haml (1314.2ms)
Completed 200 OK in 2656ms (Views: 2001.6ms | ActiveRecord: 1.5ms)

I manipulated the route urls. Still, when using the default route configuration the same problem occurs.

matejLukasik commented 6 years ago

TLDR: Check twice whether rails loads you AUTH_API_KEY ENV variable and whether you provide it to authy.

I had the same issue. The request to register the user in Authy was failing because I did not set my ENV variable AUTH_API_KEY correctly. However, this was not communicated to the UI, nor in the request itself.

I was using fish as shell, so I switched to setting the ENV variable in bash like this: export AUTHY_API_KEY=YOUR_AUTHY_API_KEY. That helped.

philnash commented 6 years ago

Hey @jonhue, this was raised a long time ago and I don't know if it was resolved or not. I'm going to close the issue for now, but if you are still having trouble, please re-open and we can try to solve it.