Module: Aspartame::AspartameSessionsHelper

Included in:
ApplicationHelper, AspartameSessionsController, AspartameTranslationsController, AspartameUsersController
Defined in:
app/helpers/aspartame/aspartame_sessions_helper.rb

Instance Method Summary collapse

Instance Method Details

#aspartame_current_userObject



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(cookies[: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

Returns:

  • (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_user)
  cookies.permanent[:aspartame_remember_token] = aspartame_user.remember_token
  self.aspartame_current_user = aspartame_user
end

#aspartame_sign_outObject



31
32
33
34
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 31

def aspartame_sign_out
  self.aspartame_current_user = nil
  cookies.delete(:aspartame_remember_token)
end

#aspartame_signed_in?Boolean

Returns:

  • (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_userObject



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 , notice: "Please sign in."
  end
end

#aspartame_store_locationObject



41
42
43
# File 'app/helpers/aspartame/aspartame_sessions_helper.rb', line 41

def aspartame_store_location
  session[:aspartame_return_to] = request.fullpath
end