Commit 727e0bb294dd3cc21d87132ea76eed704956d9f4
1 parent
12f1c20e
Exists in
master
and in
28 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 | 51 | rescue |
| 52 | 52 | #User not saved |
| 53 | 53 | end |
| 54 | + else | |
| 55 | + user = nil | |
| 54 | 56 | end |
| 57 | + | |
| 55 | 58 | else |
| 56 | 59 | |
| 57 | 60 | return nil if !user.activated? |
| ... | ... | @@ -60,6 +63,7 @@ class LdapPlugin < Noosfero::Plugin |
| 60 | 63 | # user si defined as nil if ldap authentication failed |
| 61 | 64 | user = nil if ldap.authenticate(login, password).nil? |
| 62 | 65 | rescue Net::LDAP::LdapError => e |
| 66 | + user = nil | |
| 63 | 67 | puts "LDAP is not configured correctly" |
| 64 | 68 | end |
| 65 | 69 | end | ... | ... |
plugins/ldap/test/functional/account_controller_plugin_test.rb
| ... | ... | @@ -22,6 +22,11 @@ class AccountControllerPluginTest < ActionController::TestCase |
| 22 | 22 | assert_nil session[:user] |
| 23 | 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 | 30 | should 'authenticate user if its a local user but is not a ldap user' do |
| 26 | 31 | user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test') |
| 27 | 32 | user.activate | ... | ... |