Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails devise_ldap_authenticatable Initial Login Failing

Firstly, I'm relatively new to Rails, and probably overlooked something quite simple.

I'm using the Devise and devise_ldap_authenticatable Gems to perform authentication against Active Directory. Authentication to AD is working, however, when a user logs in for the first time the user is redirected back to the /login page. An entry for the user is added to the database, and a flash message appears on the page (see below). Once the user has authenticated the first time, and an entry for the user has been added to the local database all subsequent logins work as expected and the user is redirected to the root_path.

Note: I know what's going on with the flash message, I just suspect that something is calling an error that doesn't exist in the devise.en.yml because something else is wrong. I can easily add a message to that file to fix that. I left the problem to assist with troubleshooting. I suspect the correct translation would be: en.devise.sessions.signed_in: 'Signed in successfully.'

  • Using devise (1.5.3)
  • Using net-ldap (0.2.2)
  • Using devise_ldap_authenticatable (0.5.1)

Flash Message:

<div class="notice">translation missing: en.devise.user.user.signed_in</div>

Relevant Routes:

devise_for :users, :skip => [:sessions]
as :user do
    get "/login", :to => "user#new", :as => :new_user_session
    post "/login", :to => "user#create", :as => :user_session
    delete "/logout", :to => "user#destroy", :as => :destroy_user_session
end

application_controller.rb:

class ApplicationController < ActionController::Base
    rescue_from DeviseLdapAuthenticatable::LdapException do |exception|
        render :text => exception, :status => 500
    end
    protect_from_forgery

    # Require user to be authenticated to dispay the page.
    before_filter :authenticate_user!
end
like image 440
Aaron Lake Avatar asked Jan 29 '26 14:01

Aaron Lake


1 Answers

Probably a rookie mistake, I ended up removing :validatable from app/models/user.rb and everything worked as it should. Hopefully this will save someone from being as frustrated as I was.

like image 166
Aaron Lake Avatar answered Feb 01 '26 06:02

Aaron Lake