2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/filters/AdminRequired.rb', line 2
def self.filter(controller)
unless controller.session[:user]
controller.flash[:warning] = 'Please login to continue'
controller.session[:return_to] = controller.request.fullpath
controller.redirect_to :controller => 'users', :action => 'login'
return false
end
unless controller.session[:user] and controller.session[:user][:role] <= 1
controller.flash[:warning] = 'Please login to continue'
controller.session[:return_to] = controller.request.fullpath
controller.render :inline => "You are not authorized for this part of the application! Return <a href='/'>home</a>"
return false
end
return true
end
|