Commit 727e0bb294dd3cc21d87132ea76eed704956d9f4
1 parent
12f1c20e
Exists in
master
and in
29 other branches
should not return an user if it does not exist
Showing
2 changed files
with
9 additions
and
0 deletions
Show diff stats
plugins/ldap/lib/ldap_plugin.rb
| @@ -51,7 +51,10 @@ class LdapPlugin < Noosfero::Plugin | @@ -51,7 +51,10 @@ class LdapPlugin < Noosfero::Plugin | ||
| 51 | rescue | 51 | rescue |
| 52 | #User not saved | 52 | #User not saved |
| 53 | end | 53 | end |
| 54 | + else | ||
| 55 | + user = nil | ||
| 54 | end | 56 | end |
| 57 | + | ||
| 55 | else | 58 | else |
| 56 | 59 | ||
| 57 | return nil if !user.activated? | 60 | return nil if !user.activated? |
| @@ -60,6 +63,7 @@ class LdapPlugin < Noosfero::Plugin | @@ -60,6 +63,7 @@ class LdapPlugin < Noosfero::Plugin | ||
| 60 | # user si defined as nil if ldap authentication failed | 63 | # user si defined as nil if ldap authentication failed |
| 61 | user = nil if ldap.authenticate(login, password).nil? | 64 | user = nil if ldap.authenticate(login, password).nil? |
| 62 | rescue Net::LDAP::LdapError => e | 65 | rescue Net::LDAP::LdapError => e |
| 66 | + user = nil | ||
| 63 | puts "LDAP is not configured correctly" | 67 | puts "LDAP is not configured correctly" |
| 64 | end | 68 | end |
| 65 | end | 69 | end |
plugins/ldap/test/functional/account_controller_plugin_test.rb
| @@ -22,6 +22,11 @@ class AccountControllerPluginTest < ActionController::TestCase | @@ -22,6 +22,11 @@ class AccountControllerPluginTest < ActionController::TestCase | ||
| 22 | assert_nil session[:user] | 22 | assert_nil session[:user] |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | + should 'diplay not logged message if the user is not a local user or a ldap user' do | ||
| 26 | + post :login, :user => {:login => 'someuser', :password => 'somepass'} | ||
| 27 | + assert_equal 'Incorrect username or password', session[:notice] | ||
| 28 | + end | ||
| 29 | + | ||
| 25 | should 'authenticate user if its a local user but is not a ldap user' do | 30 | should 'authenticate user if its a local user but is not a ldap user' do |
| 26 | user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test') | 31 | user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test') |
| 27 | user.activate | 32 | user.activate |