Module: SessionsHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/sessions_helper.rb
Instance Method Summary collapse
- #preferences_customer_type=(type) ⇒ Object
- #preferences_customer_type? ⇒ Boolean
-
#signed_in? ⇒ Boolean
def sign_in(user) cookies.permanent = user.remember_token self.current_user = user end.
- #signed_in_user ⇒ Object
- #store_location ⇒ Object
Instance Method Details
#preferences_customer_type=(type) ⇒ Object
49 50 51 |
# File 'app/helpers/sessions_helper.rb', line 49 def preferences_customer_type=(type) session[:customer_type] = type; end |
#preferences_customer_type? ⇒ Boolean
53 54 55 |
# File 'app/helpers/sessions_helper.rb', line 53 def preferences_customer_type? session[:customer_type] || :pj end |
#signed_in? ⇒ Boolean
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
self.current_user = user
end
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
def current_user=(user)
@current_user = user
end
def current_user
#logger.debug "HELPER Session: getCurrentUser User: #{@current_user} | TOKEN: #{cookies[:remember_token]} "
@current_user ||= User.find_by_remember_token(cookies[:remember_token])
end
def current_user?(user)
user == current_user
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)
end
34 35 36 |
# File 'app/helpers/sessions_helper.rb', line 34 def signed_in? !current_user.nil? end |
#signed_in_user ⇒ Object
38 39 40 41 42 43 |
# File 'app/helpers/sessions_helper.rb', line 38 def signed_in_user unless signed_in? store_location redirect_to new_user_session_path, notice: t("session.erros.restrict_redirected") end end |
#store_location ⇒ Object
45 46 47 |
# File 'app/helpers/sessions_helper.rb', line 45 def store_location session[:return_to] = request.fullpath end |