blob: 0d6e5d13c3dd9edf2aabd8b790dfe7bb56445a0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
def logged_in?
!!current_user
end
helper_method :logged_in?
def authorize
access_denied unless logged_in?
end
def admin?
current_user && current_user.is_admin?
end
helper_method :admin?
def authorize_admin
access_denied unless admin?
end
def access_denied
redirect_to login_url, :alert => "Not authorized"
end
end
|