added an administrative method intended to be used as a before filter within the application controller as well as an is_admin? method
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
before_filter :authenticated
|
before_filter :authenticated
|
||||||
helper_method :current_user
|
helper_method :current_user, :is_admin?
|
||||||
|
|
||||||
# Our security guy keep talking about sea-surfing, cool story bro.
|
# Our security guy keep talking about sea-surfing, cool story bro.
|
||||||
# protect_from_forgery
|
# protect_from_forgery
|
||||||
@@ -16,4 +16,15 @@ class ApplicationController < ActionController::Base
|
|||||||
redirect_to root_url and reset_session if not current_user
|
redirect_to root_url and reset_session if not current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_admin?
|
||||||
|
admin = current_user.admin if current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
def administrative
|
||||||
|
if not is_admin?
|
||||||
|
reset_session
|
||||||
|
redirect_to login_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class DashboardController < ApplicationController
|
class DashboardController < ApplicationController
|
||||||
|
|
||||||
def home
|
def home
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user