Created
November 30, 2012 16:20
-
-
Save adgilfillan/4176767 to your computer and use it in GitHub Desktop.
Admin/User role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authenticate_self_or_admin | |
m = Member.find(session[:member_id]) | |
if m.role == 'Admin' | |
elsif session[:member_id].nil? | |
flash[:alert] = 'You need to login first.' | |
redirect_to(:controller => 'admin', :action => 'login') | |
elsif session[:member_id].to_s != params[:id] | |
flash[:alert] = 'You cannot perform this action.' | |
redirect_to(:controller => 'admin', :action => 'login') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment