Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug devise/warden?

I am trying to setup devise in my rails app. It was working nicely, but now I am not able to login as any of my users I get 'Invalid email or password.' I would like to get more insight why its not authenticating.

Is there any devise configuration settings that shed some more light? i.e. what is the query being used to find the user, et c ...

Thanks!

like image 452
Jonathan Avatar asked Jul 14 '10 21:07

Jonathan


People also ask

What is warden in devise?

Warden is a gem that takes care of fetching authentication details from the request and fetching the user. Devise requires Warden to be added as a middleware.

What does warden authenticate do?

Warden is a Ruby gem that allows you to perform authentication through Rack Middleware. When you're writing an application's authentication from scratch it's normal to do this entirely within the application but there are several advantages to using Warden.


1 Answers

Normally Devise not provide an accurate logging system, maybe overriding the default controller you can catch what is going wrong. Try something like this:

# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
  def new
    super # or perform some custom task
  end

end 

Remember then to configure the routes too.

# app/config/routes.rb
devise_for :users, :controllers => {:sessions => "sessions"}

For more details about the default Devise sessions controller take a look at this: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb

OR

You can login with ssh to your remote server, run rails console and do manually some checks (check that users exist, try a login via console,...), alternatively you can create a rake task with some testing and run remotely.

like image 161
damoiser Avatar answered Oct 07 '22 11:10

damoiser