mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Move the access control to a dedicated helper
This commit is contained in:
parent
95cb7ec799
commit
2d4ba48ad4
2 changed files with 8 additions and 6 deletions
|
|
@ -154,6 +154,13 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def admin_or_self_login_required
|
||||
unless User.find(session['user_id']).is_admin || session['user_id'] == params[:id]
|
||||
render :body => t('errors.user_unauthorized'), :status => 401
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_back_or_home
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default root_url }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue