From 727e0bb294dd3cc21d87132ea76eed704956d9f4 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Thu, 14 Mar 2013 17:44:55 -0300 Subject: [PATCH] should not return an user if it does not exist --- plugins/ldap/lib/ldap_plugin.rb | 4 ++++ plugins/ldap/test/functional/account_controller_plugin_test.rb | 5 +++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/plugins/ldap/lib/ldap_plugin.rb b/plugins/ldap/lib/ldap_plugin.rb index 23e2f8a..3a2618c 100644 --- a/plugins/ldap/lib/ldap_plugin.rb +++ b/plugins/ldap/lib/ldap_plugin.rb @@ -51,7 +51,10 @@ class LdapPlugin < Noosfero::Plugin rescue #User not saved end + else + user = nil end + else return nil if !user.activated? @@ -60,6 +63,7 @@ class LdapPlugin < Noosfero::Plugin # user si defined as nil if ldap authentication failed user = nil if ldap.authenticate(login, password).nil? rescue Net::LDAP::LdapError => e + user = nil puts "LDAP is not configured correctly" end end diff --git a/plugins/ldap/test/functional/account_controller_plugin_test.rb b/plugins/ldap/test/functional/account_controller_plugin_test.rb index 000178e..ada70f1 100644 --- a/plugins/ldap/test/functional/account_controller_plugin_test.rb +++ b/plugins/ldap/test/functional/account_controller_plugin_test.rb @@ -22,6 +22,11 @@ class AccountControllerPluginTest < ActionController::TestCase assert_nil session[:user] end + should 'diplay not logged message if the user is not a local user or a ldap user' do + post :login, :user => {:login => 'someuser', :password => 'somepass'} + assert_equal 'Incorrect username or password', session[:notice] + end + should 'authenticate user if its a local user but is not a ldap user' do user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test') user.activate -- libgit2 0.21.2