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.'
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With