Class: Admin::Kitsune::KitsuneController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/kitsune/kitsune_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



40
41
42
43
44
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 40

def authenticate
  if Kitsune.authenticate
    deny_access unless signed_in?
  end
end

#clear_return_toObject



66
67
68
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 66

def clear_return_to
  session[:return_to] = nil
end

#current_userObject



8
9
10
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 8

def current_user
  @_current_user ||= user_from_cookie
end

#current_user=(user) ⇒ Object



12
13
14
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 12

def current_user=(user)
  @_current_user = user
end

#deny_access(flash_message = nil) ⇒ Object



46
47
48
49
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 46

def deny_access(flash_message = nil)
  flash[:notice] = flash_message if flash_message
  redirect_to url_for(:controller => 'admin/kitsune/sessions', :action => 'new')
end

#redirect_back_or(default) ⇒ Object



57
58
59
60
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 57

def redirect_back_or(default)
  redirect_to(return_to || default)
  clear_return_to
end

#return_toObject



62
63
64
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 62

def return_to
  session[:return_to] || params[:return_to]
end

#sign_in(user) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 20

def (user)
  if user
    user.remember_me!
    cookies[:remember_token] = {
      :value => user.remember_token,
      :expires => 1.year.from_now.utc
    }
    current_user = user
  end
end

#sign_outObject



31
32
33
34
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 31

def sign_out
  cookies.delete(:remember_token)
  current_user = nil
end

#signed_in?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 16

def signed_in?
  !current_user.nil?
end

#signed_out?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 36

def signed_out?
  current_user.nil?
end


51
52
53
54
55
# File 'app/controllers/admin/kitsune/kitsune_controller.rb', line 51

def user_from_cookie
  if token = cookies[:remember_token]
    KitsuneUser.find_by_remember_token(token)
  end
end