Module: Challah::UserFindable::ClassMethods
- Defined in:
- lib/challah/concerns/user/findable.rb
Instance Method Summary collapse
- #active ⇒ Object
-
#find_for_session(username_or_email) ⇒ Object
Find a user instance by username first, or email address if needed.
- #inactive ⇒ Object
Instance Method Details
#active ⇒ Object
10 11 12 |
# File 'lib/challah/concerns/user/findable.rb', line 10 def active where(active: true) end |
#find_for_session(username_or_email) ⇒ Object
Find a user instance by username first, or email address if needed. If no user is found matching, return nil
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/challah/concerns/user/findable.rb', line 16 def find_for_session(username_or_email) return nil if username_or_email.to_s.blank? result = nil if username_or_email.to_s.include?('@') result = where(email: username_or_email).first end if !result uid = username_or_email.to_s.downcase.strip = self. = .where(provider: :password, uid: uid) = .first if result = .user end end result end |
#inactive ⇒ Object
40 41 42 |
# File 'lib/challah/concerns/user/findable.rb', line 40 def inactive where.not(active: true) end |