Commit bf1dc29257ec7652392ec9678aa32bd04c8e5756

Authored by Aurélio A. Heckert
Committed by Daniela Feitosa
1 parent 91261f4b

Makes LDAP password_recovery configurable

plugins/ldap/lib/ext/environment.rb
... ... @@ -6,7 +6,7 @@ class Environment
6 6  
7 7 validates_presence_of :ldap_plugin_host, :if => lambda {|env| !env.ldap_plugin.blank? }
8 8  
9   - attr_accessible :ldap_plugin_host, :ldap_plugin_port, :ldap_plugin_tls, :ldap_plugin_onthefly_register, :ldap_plugin_account, :ldap_plugin_account_password, :ldap_plugin_filter, :ldap_plugin_base_dn, :ldap_plugin_attr_mail, :ldap_plugin_attr_login, :ldap_plugin_attr_fullname
  9 + attr_accessible :ldap_plugin_host, :ldap_plugin_port, :ldap_plugin_tls, :ldap_plugin_onthefly_register, :ldap_plugin_account, :ldap_plugin_account_password, :ldap_plugin_filter, :ldap_plugin_base_dn, :ldap_plugin_attr_mail, :ldap_plugin_attr_login, :ldap_plugin_attr_fullname, :ldap_plugin_allow_password_recovery
10 10  
11 11 def ldap_plugin_attributes
12 12 self.ldap_plugin || {}
... ... @@ -113,4 +113,13 @@ class Environment
113 113 self.ldap_plugin['tls'] = (value.to_s == '1') ? true : false
114 114 end
115 115  
  116 + def ldap_plugin_allow_password_recovery
  117 + self.ldap_plugin['allow_password_recovery'] ||= false
  118 + end
  119 +
  120 + def ldap_plugin_allow_password_recovery= value
  121 + self.ldap_plugin = {} if self.ldap_plugin.blank?
  122 + self.ldap_plugin['allow_password_recovery'] = (value.to_i == 1)
  123 + end
  124 +
116 125 end
... ...
plugins/ldap/lib/ldap_plugin.rb
... ... @@ -36,7 +36,7 @@ class LdapPlugin < Noosfero::Plugin
36 36 end
37 37  
38 38 def allow_password_recovery
39   - false
  39 + context.environment.ldap_plugin['allow_password_recovery']
40 40 end
41 41  
42 42 def alternative_authentication
... ...
plugins/ldap/test/unit/ldap_plugin_test.rb
... ... @@ -9,6 +9,8 @@ class LdapPluginTest < ActiveSupport::TestCase
9 9  
10 10 should "not allow password recovery" do
11 11 plugin = LdapPlugin.new
  12 + plugin.context = mock
  13 + plugin.context.expects(:environment).returns(Environment.default)
12 14 refute plugin.allow_password_recovery
13 15 end
14 16  
... ...
plugins/ldap/views/ldap_plugin_admin/index.html.erb
... ... @@ -4,7 +4,7 @@
4 4  
5 5 <table>
6 6 <tr>
7   - <th><%= c_('Configuration') %></th>
  7 + <th><%= _('LDAP Configuration') %></th>
8 8 <th><%= _('Value') %></th>
9 9 </tr>
10 10 <tr>
... ... @@ -43,7 +43,8 @@
43 43  
44 44 <table>
45 45 <tr>
46   - <th colspan='2'> <%= _('Attributes') %> </th>
  46 + <th><%= _('Attributes') %></th>
  47 + <th><%= _('LDAP Field') %></th>
47 48 </tr>
48 49 <tr>
49 50 <td><%= c_('Login') %></td>
... ... @@ -59,6 +60,18 @@
59 60 </tr>
60 61 </table>
61 62  
  63 +<table>
  64 + <tr>
  65 + <th><%= _('Behaviour Configuration') %></th>
  66 + </tr>
  67 + <tr>
  68 + <td><label>
  69 + <%= check_box :environment, :ldap_plugin_allow_password_recovery, {}, '1', '0' %>
  70 + <%= _('Allow password recovery') %>
  71 + </label></td>
  72 + </tr>
  73 +</table>
  74 +
62 75 <div>
63 76 <% button_bar do %>
64 77 <%= submit_button('save', c_('Save changes')) %>
... ...