Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with Active Admin #7

Closed
toreym opened this issue Jul 4, 2013 · 10 comments
Closed

Use with Active Admin #7

toreym opened this issue Jul 4, 2013 · 10 comments

Comments

@toreym
Copy link

toreym commented Jul 4, 2013

I'm getting a route not found error when using Active Admin. I was able to get it to work by changing this line. But not sure the best way to fix it.

# respond_with resource, :location => { :controller => 'checkga', :action => 'show', :id => tmpid}
redirect_to "/admin/checkga?id=#{tmpid}"
@xntrik
Copy link
Contributor

xntrik commented Jul 9, 2013

Hi Torey, can you elaborate on the Active Admin ? Keen to figure out why this isn't working for you. (Can you also shoot me a copy of your rake routes output?)

@cp
Copy link

cp commented Oct 30, 2013

Yeah, I seem to be getting this as well.

@ValkyrieUK
Copy link

Did anything come of this issue ?

@toreym
Copy link
Author

toreym commented Feb 13, 2014

I'm sorry I've kept the fix/workaround I had above. But haven't had time to research a proper fix.

@xntrik
Copy link
Contributor

xntrik commented Mar 16, 2014

It appears that in this instance the devise routes are underneath active_admin/devise instead of just devise.

Unfortunately, the above fix looks like the quickest patch at this point in time, until I can at least figure out how dynamically add the routes for devise_google_authenticator under active_admin/devise instead of just devise/

@paulstrife
Copy link

I am trying to do the same but I had no luck. Where I should put this fix?
I tried to make a route like

get 'active_admin/admin/checkga', to: 'active_admin/devise/checkga#show'

but I get a 「Unable to autoload constant ActiveAdmin::Devise::CheckgaController, expected /Users/interbooks04/Documents/Aptana Studio 3 Workspace/ib-global/app/controllers/active_admin/devise/checkga_controller.rb to define it」error.

@paulstrife
Copy link

ok I fixed in an alternative way.
in routes.rb
get 'admin/checkga', to: 'active_admin/devise/checkga#show'
and copied the checkga_controller.rb from the source code to /controllers/devise/checkga_controller.rb without modifying anything (only the redirect path after login to admin_root_path)

xntrik added a commit that referenced this issue Mar 28, 2014
@xntrik
Copy link
Contributor

xntrik commented Mar 28, 2014

Hi All, I've made a minor change to the checkga path where it more dynamically determines where to redirect the user after they've authenticated, prior to the Google Token being checked.

I've tested this with Rails 4.0.4 and Active Admin 1.0.0.pre.

To make this work I performed the following steps
rails new aatest # generate a new rails app called aatest
added gem 'activeadmin', github: 'gregbell/active_admin' into the Gemfile
added gem 'devise_google_authenticator', '0.3.11' into the Gemfile
bundle # update the gems
rails g active_admin:install # installs the active admin capability
rake db:migrate # migrate these db changes
rails g devise_google_authenticator:install # installs this gem
rails g devise_google_authenticator AdminUser # modifies the Active Admin default user for google auth capability
rake db:migrate # migrate the google auth db changes
rails c # logs into the rails console (we need to set default secrets for the users)

AdminUser.where(:gauth_secret => nil).each do |user|
user.send(:assign_auth_secret)
user.save
end
exit

added root 'admin/dashboard#index' into routes.rb # need a root route
modified devise.google_authenticator.en.yml in config/locales such that checkga: and displayqr: i2n settings where for admin_user instead of user

rails s # starts the rails server

Logged into the app
Visited /admin/displayqr to enrole and enable QR

Voila ..

I hope this works for you guys!

@xntrik
Copy link
Contributor

xntrik commented Mar 28, 2014

Closing for the moment, but, feel free to open again if it remains broken.

@xntrik xntrik closed this as completed Mar 28, 2014
@imam-scs
Copy link

imam-scs commented Nov 6, 2018

Hi , I have installed gem 'devise_google_authenticator' in rails 5.2.1 but i got error i.e,Gem Load Error is: undefined method `to_prepare' for ActionDispatch::Callbacks:Class
Did you mean? to_param , please give me suggestion

giancarloeje pushed a commit to gdslink/devise_google_authenticator that referenced this issue Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants