mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 05:04:03 +00:00
First checkin
This commit is contained in:
parent
f207e2c8b7
commit
90b30db9e8
260 changed files with 37349 additions and 0 deletions
42
app/controllers/application_controller.rb
Normal file
42
app/controllers/application_controller.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
include ApplicationHelper
|
||||
|
||||
protect_from_forgery
|
||||
|
||||
def verify_user
|
||||
:authenticate_user!
|
||||
|
||||
if (current_user.nil?)
|
||||
redirect_to '/accounts/sign_in'
|
||||
return
|
||||
end
|
||||
|
||||
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
|
||||
end
|
||||
|
||||
def organizer_or_admin?
|
||||
has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
|
||||
end
|
||||
|
||||
def verify_organizer
|
||||
verify_user
|
||||
|
||||
## Todo simplify this
|
||||
redirect_to '/' unless has_role?(current_user, 'admin') || has_role?(current_user, 'organizer')
|
||||
end
|
||||
|
||||
def verify_admin
|
||||
verify_user
|
||||
|
||||
redirect_to '/' unless has_role?(current_user, 'admin')
|
||||
end
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= AdminAbility.new(current_user)
|
||||
end
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
Rails.logger.debug("Access denied!")
|
||||
redirect_to '/', :alert => exception.message
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue