Select Git revision
styleguide.md
application_controller.rb 1004 B
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [ :invitation_token ])
devise_parameter_sanitizer.permit(:account_update) do |u|
u.permit(:name, :email, :password, :password_confirmation, :avatar_color, :darkmode, :languages_from,
:languages_to, :telegram_username, :current_password)
end
end
def authorize_shiftcoordinator
authorize_role("shift_coordinator")
end
def redirect_back_with_error(message)
redirect_back(fallback_location: root_path, alert: message)
end
def authorize_role(role_name)
return if current_user&.has_role?(role_name)
render plain: "Forbidden", status: :forbidden
end
def authorize_permission(permission_name)
return if current_user&.has_permission?(permission_name)
render plain: "Forbidden", status: :forbidden
end
end