Class: CmsUser
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CmsUser
- Defined in:
- app/models/cms_user.rb
Instance Attribute Summary collapse
-
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
Class Method Summary collapse
Instance Method Summary collapse
- #full_name ⇒ Object
-
#password ⇒ Object
‘password’ is a virtual attribute.
- #password=(pwd) ⇒ Object
Instance Attribute Details
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
14 15 16 |
# File 'app/models/cms_user.rb', line 14 def password_confirmation @password_confirmation end |
Class Method Details
.authenticate(login, password, authentication, ldap_hostname, ldap_base_DN, ldap_uid) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/cms_user.rb', line 33 def self.authenticate(login, password, authentication, ldap_hostname, ldap_base_DN, ldap_uid) if authentication == 'LDAP' username = login if (password.empty?) then return nil end ldap = Net::LDAP.new(:host => ldap_hostname, :base => ldap_base_DN) filter = Net::LDAP::Filter.eq(ldap_uid, login) ldap.search(:filter => filter) {|entry| login = entry.dn} ldap.auth(login, password) if ldap.bind user = CmsUser.find_by_login_and_disabled(username, false) # need to check if user is in the database and not disabled if (user) return user else #user is in LDAP but not in local database return nil end else #authentication failed return nil end else user= self.find_by_login(login) if user expected_password = encrypted_password(password, user.salt) if user.hashed_password != expected_password user = nil end end user end end |
Instance Method Details
#full_name ⇒ Object
29 30 31 |
# File 'app/models/cms_user.rb', line 29 def full_name [first_name, last_name].join(' ') end |
#password ⇒ Object
‘password’ is a virtual attribute
18 19 20 |
# File 'app/models/cms_user.rb', line 18 def password @password end |
#password=(pwd) ⇒ Object
22 23 24 25 26 27 |
# File 'app/models/cms_user.rb', line 22 def password=(pwd) @password = pwd return if pwd.blank? create_new_salt self.hashed_password = CmsUser.encrypted_password(self.password, self.salt) end |