AsteriskLabs/devise_google_authenticator

No route matches {:action=>"show", :controller=>"displayqr"}

Closed this issue · 19 comments

I don't seem to have anything in the routes.rb for google authenticator. Should I have ?

Anyway when I signup (this is a new rails 4 app) I get the above error.

Working on this issue at the moment. Need a clever way to get the correct
respond_with dynamically back into the checkga controller.
On 27 Mar 2014 21:32, "carbonwallet" notifications@github.com wrote:

I don't seem to have anything in the routes.rb for google authenticator.
Should I have ?

Anyway when I signup (this is a new rails 4 app) I get the above error.


Reply to this email directly or view it on GitHubhttps://github.com//issues/24
.

Great thanks.

I've made a slight change to how some of the routes are dynamically generated.

This gem's routes are managed through devise, so you'll need to make sure that you've installed the devise gem first.

Can you give me the output of your rake routes command?

rake routes
                  Prefix Verb   URI Pattern                    Controller#Action
                    root GET    /                              home#index
        new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
            user_session POST   /users/sign_in(.:format)       devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
           user_password POST   /users/password(.:format)      devise/passwords#create
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PATCH  /users/password(.:format)      devise/passwords#update
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        registrations#cancel
       user_registration POST   /users(.:format)               registrations#create
   new_user_registration GET    /users/sign_up(.:format)       registrations#new
  edit_user_registration GET    /users/edit(.:format)          registrations#edit
                         PATCH  /users(.:format)               registrations#update
                         PUT    /users(.:format)               registrations#update
                         DELETE /users(.:format)               registrations#destroy
          user_displayqr GET    /users/displayqr(.:format)     devise/displayqr#show
                         PATCH  /users/displayqr(.:format)     devise/displayqr#update
                         PUT    /users/displayqr(.:format)     devise/displayqr#update
            user_checkga GET    /users/checkga(.:format)       devise/checkga#show
                         PATCH  /users/checkga(.:format)       devise/checkga#update
                         PUT    /users/checkga(.:format)       devise/checkga#update
                   users GET    /users(.:format)               users#index
                         POST   /users(.:format)               users#create
                new_user GET    /users/new(.:format)           users#new
               edit_user GET    /users/:id/edit(.:format)      users#edit
                    user GET    /users/:id(.:format)           users#show
                         PATCH  /users/:id(.:format)           users#update
                         PUT    /users/:id(.:format)           users#update
                         DELETE /users/:id(.:format)           users#destroy

I've recently made a change that more gracefully determines how to respond_with after the user successfully enters their password. From version 0.3.11 this is in place, although the current version is 0.3.13.

Can you give it a shot with this updated gem and let me know if the error persists?

I'm using GEM 0.3.13 and I still get the same error.

It's reproducible from a fresh rails install. i..e

rails new newapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

Then add the authenticator gem and try to register.

I'm also getting the same error

ActionController::UrlGenerationError at /users
No route matches {:action=>"show", :controller=>"devise_invitable/displayqr"}

What happens on this one? Some progress?

Sorry for the delay in this, will check the failed condition as per @carbonwallet's instructions above.

I actually run into this when I specify a registration controller in my routes:

  devise_for :users, :controllers => { :registrations => "registrations" }

Any ideas? As a side note I'm trying to redirect to a certain path after sign up but displayqr seems to be hijacking that.

Hi @joshrendek - the hijacking of the registration controller is also what devise_google_authenticator does. So you're probably running into a race condition after sign-up. I think I'll add a configurable option to enable/disable the displayqr page after sign-up. This way, you can configure this to disable, and therefore users won't be redirected to displayqr during sign-up, and the only way they can enable QR is if they visit the displayqr page.

@xntrik can you tell me where to look so i can monkey patch this for now? I wasn't able to find anything digging through the source :(

I'm still not entirely sure how to recreate this issue, but, I have a feeling it either relates to custom devise controllers (as in @joshrendek's situation) or something else? With the current master gem (which I am close to releasing as version 0.3.15), following these steps I'm not getting this issue. This is with ruby 2.0.0-p481 and rails 4.1.5.

Execute:

rails new testapp
cd testapp
vi Gemfile # or edit with whatever text editor you like

add:

gem 'devise'
gem 'devise_google_authenticator'

Then re-bundle and install devise and devise_google_authenticator, and configure it for the 'user' model

bundle
rails g devise:install
rails g devise user
rails g devise_google_authenticator:install
rails g devise_google_authenticator user

We then have to edit the app to use devise.

vi app/controllers/application_controller.rb

Add just before the end of the class

before_filter :authenticate_user!

Edit the routes file

vi config/routes.rb

Set a root. The only routes in here now should be devise_for :users, and whatever root you set

root 'home#index'

Create the home controller

vi app/controllers/home_controller.rb

Put something like this in there:

class HomeController < ApplicationController
  def index
  end
end

Create the home view

mkdir app/views/home
vi app/views/home/index.html.erb

Create a simple view:

Welcome home

Migrate the database

rake db:migrate

Then start the server

rails s

Now, when you visit http://localhost:3000 you'll be forwarded to the sign-in page, if you click 'sign-up', and enter an email and password twice, you should end up at http://localhost:3000/users/displayqr.

The output of rake routes should look like:

                  Prefix Verb   URI Pattern                        Controller#Action
        new_user_session GET    /users/sign_in(.:format)           devise/sessions#new
            user_session POST   /users/sign_in(.:format)           devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)          devise/sessions#destroy
           user_password POST   /users/password(.:format)          devise/passwords#create
       new_user_password GET    /users/password/new(.:format)      devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)     devise/passwords#edit
                         PATCH  /users/password(.:format)          devise/passwords#update
                         PUT    /users/password(.:format)          devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)            devise/registrations#cancel
       user_registration POST   /users(.:format)                   devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)           devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)              devise/registrations#edit
                         PATCH  /users(.:format)                   devise/registrations#update
                         PUT    /users(.:format)                   devise/registrations#update
                         DELETE /users(.:format)                   devise/registrations#destroy
  refresh_user_displayqr POST   /users/displayqr/refresh(.:format) devise/displayqr#refresh
          user_displayqr GET    /users/displayqr(.:format)         devise/displayqr#show
                         PATCH  /users/displayqr(.:format)         devise/displayqr#update
                         PUT    /users/displayqr(.:format)         devise/displayqr#update
            user_checkga GET    /users/checkga(.:format)           devise/checkga#show
                         PATCH  /users/checkga(.:format)           devise/checkga#update
                         PUT    /users/checkga(.:format)           devise/checkga#update
                    root GET    /                                  home#index

If you don't want to redirect to the users/displayqr page after sign-up, you can uncomment the config.ga_bypass_signup option in config/initializers/devise.rb.

I'm keen to try and squash this bug - and I hope the above helps.

Haha, sorry @joshrendek - just pushed up to the repo now. But, you can see the changes in d0de660

Awesome its working :)

So I assume that this issue is now closed (or should be 😉 )?

Hi @f3ndot - I'm half waiting on whether @carbonwallet, @allcentury or @zdraganov are still having issues.

working for me now - thanks @xntrik

I'm going to close this - but - if anyone sees these errors this can be re-opened.