Module: Aspartame::AspartameSessionsHelper
- Included in:
- ApplicationHelper, AspartameSessionsController, AspartameTranslationsController, AspartameUsersController
- Defined in:
- app/helpers/aspartame/aspartame_sessions_helper.rb
Instance Method Summary collapse
- #aspartame_current_user ⇒ Object
- #aspartame_current_user=(aspartame_user) ⇒ Object
- #aspartame_current_user?(aspartame_user) ⇒ Boolean
- #aspartame_redirect_back_or(default) ⇒ Object
- #aspartame_sign_in(aspartame_user) ⇒ Object
- #aspartame_sign_out ⇒ Object
- #aspartame_signed_in? ⇒ Boolean
- #aspartame_signed_in_user ⇒ Object
- #aspartame_store_location ⇒ Object
Instance Method Details
#aspartame_current_user ⇒ Object
16 17 18 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 16 def aspartame_current_user @aspartame_current_user ||= Aspartame::AspartameUser.find_by_remember_token([:aspartame_remember_token]) end |
#aspartame_current_user=(aspartame_user) ⇒ Object
12 13 14 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 12 def aspartame_current_user=(aspartame_user) @aspartame_current_user = aspartame_user end |
#aspartame_current_user?(aspartame_user) ⇒ Boolean
20 21 22 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 20 def aspartame_current_user?(aspartame_user) aspartame_user == aspartame_current_user end |
#aspartame_redirect_back_or(default) ⇒ Object
36 37 38 39 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 36 def aspartame_redirect_back_or(default) redirect_to(session[:aspartame_return_to] || default) session.delete(:aspartame_return_to) end |
#aspartame_sign_in(aspartame_user) ⇒ Object
3 4 5 6 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 3 def aspartame_sign_in(aspartame_user) .permanent[:aspartame_remember_token] = aspartame_user.remember_token self.aspartame_current_user = aspartame_user end |
#aspartame_sign_out ⇒ Object
31 32 33 34 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 31 def aspartame_sign_out self.aspartame_current_user = nil .delete(:aspartame_remember_token) end |
#aspartame_signed_in? ⇒ Boolean
8 9 10 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 8 def aspartame_signed_in? !aspartame_current_user.nil? end |
#aspartame_signed_in_user ⇒ Object
24 25 26 27 28 29 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 24 def aspartame_signed_in_user unless aspartame_signed_in? aspartame_store_location redirect_to signin_path, notice: "Please sign in." end end |
#aspartame_store_location ⇒ Object
41 42 43 |
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 41 def aspartame_store_location session[:aspartame_return_to] = request.fullpath end |