Module: Wristband::UserExtensions::ClassMethods
- Defined in:
- lib/wristband/user_extensions.rb
Instance Method Summary collapse
- #authenticate(email, password) ⇒ Object
- #execute_authentication_chain(object, list) ⇒ Object
- #roles_for_select ⇒ Object
Instance Method Details
#authenticate(email, password) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wristband/user_extensions.rb', line 10 def authenticate(email, password) self.execute_authentication_chain(self, self.wristband[:before_authentication_chain]) == false and return user = nil wristband[:login_with_fields].find do |field| user = send("find_by_#{field}", email) end (user and user.password_match?(password)) || return self.execute_authentication_chain(user, self.wristband[:after_authentication_chain]) == false and return user end |
#execute_authentication_chain(object, list) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wristband/user_extensions.rb', line 21 def execute_authentication_chain(object, list) list.each do |func| case func when Symbol,String object.send(func) == false and return false when Proc func.call(object) == false and return false end end end |
#roles_for_select ⇒ Object
32 33 34 |
# File 'lib/wristband/user_extensions.rb', line 32 def roles_for_select self.class.wristband[:roles].collect{ |k| [ k.to_s.titleize, k.to_s] } end |