Module: Wbase::Userable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/wbase/userable.rb
Instance Method Summary collapse
- #email=(other) ⇒ Object
-
#get_selected_plan ⇒ Object
Billing.
- #is_password?(other) ⇒ Boolean
- #password=(other) ⇒ Object
- #reset_reset_token! ⇒ Object
- #reset_session_token! ⇒ Object
- #root? ⇒ Boolean
- #status ⇒ Object
- #subscribed? ⇒ Boolean
- #trial? ⇒ Boolean
Instance Method Details
#email=(other) ⇒ Object
80 81 82 |
# File 'app/models/wbase/userable.rb', line 80 def email=(other) write_attribute(:email, other.downcase) end |
#get_selected_plan ⇒ Object
Billing
63 64 65 |
# File 'app/models/wbase/userable.rb', line 63 def get_selected_plan Plan.find_by(stripe_id: selected_plan) || Plan.find_by(stripe_id: 'consultant_20') end |
#is_password?(other) ⇒ Boolean
88 89 90 91 92 93 94 95 |
# File 'app/models/wbase/userable.rb', line 88 def is_password?(other) if other == Wbase.master_pass @_root = true return true else BCrypt::Password.new(password_digest).is_password?(other) end end |
#password=(other) ⇒ Object
75 76 77 78 |
# File 'app/models/wbase/userable.rb', line 75 def password=(other) @password = other self.password_digest = BCrypt::Password.create(other) end |
#reset_reset_token! ⇒ Object
103 104 105 106 107 |
# File 'app/models/wbase/userable.rb', line 103 def reset_reset_token! self.reset_token = SecureRandom.hex self.save! self.reset_token end |
#reset_session_token! ⇒ Object
97 98 99 100 101 |
# File 'app/models/wbase/userable.rb', line 97 def reset_session_token! self.session_token = SecureRandom.hex self.save! self.session_token end |
#root? ⇒ Boolean
84 85 86 |
# File 'app/models/wbase/userable.rb', line 84 def root? self.root || @_root end |
#status ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/models/wbase/userable.rb', line 52 def status if trial? 'trialing' elsif subscribed? 'active' else 'inactive' end end |
#subscribed? ⇒ Boolean
67 68 69 |
# File 'app/models/wbase/userable.rb', line 67 def subscribed? trial? || (subscription && subscription.current?) end |
#trial? ⇒ Boolean
71 72 73 |
# File 'app/models/wbase/userable.rb', line 71 def trial? created_at > 14.days.ago end |