| 1 | class ApplicationController < ActionController::Base |
| 2 | # Prevent CSRF attacks by raising an exception. |
| 3 | # For APIs, you may want to use :null_session instead. |
| 4 | protect_from_forgery with: :exception |
| 5 | before_action :set_locale, :remove_splitfire_user_id |
| 6 | |
| 7 | protected |
| 8 | |
| 9 | def access_denied(exception) |
| 10 | flash[:danger] = exception.message |
| 11 | redirect_to root_path |
| 12 | end |
| 13 | |
| 14 | def authenticate_admin! |
| 15 | redirect_to new_user_session_path unless current_user.admin? |
| 16 | end |
| 17 | |
| 18 | def remove_splitfire_user_id |
| 19 | cookies.delete(:splitfire_user_id) |
| 20 | end |
| 21 | |
| 22 | private |
| 23 | |
| 24 | def set_locale |
| 25 | I18n.locale = params[:locale] || I18n.default_locale |
| 26 | end |
| 27 | end |