Module: Barjillo::BarjiHelpers::InstanceMethods
- Defined in:
- lib/barjillo/barji_helpers.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
- #current_user ⇒ Object
- #current_user=(user) ⇒ Object
- #deny_access(flash_message = nil) ⇒ Object
- #sign_in(user) ⇒ Object
- #sign_out ⇒ Object
- #signed_in? ⇒ Boolean
- #signed_out? ⇒ Boolean
Instance Method Details
#authenticate ⇒ Object
39 40 41 |
# File 'lib/barjillo/barji_helpers.rb', line 39 def authenticate deny_access if signed_out? end |
#current_user ⇒ Object
21 22 23 |
# File 'lib/barjillo/barji_helpers.rb', line 21 def current_user @_current_user ||= end |
#current_user=(user) ⇒ Object
25 26 27 |
# File 'lib/barjillo/barji_helpers.rb', line 25 def current_user=(user) @_current_user = user end |
#deny_access(flash_message = nil) ⇒ Object
62 63 64 65 66 |
# File 'lib/barjillo/barji_helpers.rb', line 62 def deny_access( = nil) store_location flash[:failure] = if redirect_to(signup_url) end |
#sign_in(user) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/barjillo/barji_helpers.rb', line 44 def sign_in(user) if user [:remember_token] = { :value => user.remember_token, :expires => 1.month.from_now.utc } current_user = user end end |
#sign_out ⇒ Object
55 56 57 58 59 |
# File 'lib/barjillo/barji_helpers.rb', line 55 def sign_out current_user.reset_remember_token! if current_user .delete(:remember_token) current_user = nil end |
#signed_in? ⇒ Boolean
30 31 32 |
# File 'lib/barjillo/barji_helpers.rb', line 30 def signed_in? current_user.present? end |
#signed_out? ⇒ Boolean
35 36 37 |
# File 'lib/barjillo/barji_helpers.rb', line 35 def signed_out? current_user.nil? end |