<commit_before>require "application_responder"

class ApplicationController < ActionController::Base
  self.responder = ApplicationResponder
  respond_to :html

  protect_from_forgery with: :exception

  before_action :configure_permitted_parameters, if: :devise_controller?

  before_action :authenticate_user!

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) do |u|
      u.permit :username, :email, :password, :password_confirmation
    end

    devise_parameter_sanitizer.for(:account_update) do |u|
      u.permit(:username, :email, :password, :password_confirmation,
               :current_password)
    end

    devise_parameter_sanitizer.for(:accept_invitation)
      .concat [:first_name, :last_name, :phone]

    devise_parameter_sanitizer.for(:accept_invitation) do |u|
      u.permit(:first_name, :last_name, :phone, :password,
               :password_confirmation, :invitation_token)
    end
  end

  def authorize_admin!
    current_user.admin? or redirect_to :root and return
  end
end<commit_msg>set flash if admin authorisation fails<commit_after>require "application_responder"

class ApplicationController < ActionController::Base
  self.responder = ApplicationResponder
  respond_to :html

  protect_from_forgery with: :exception

  before_action :configure_permitted_parameters, if: :devise_controller?

  before_action :authenticate_user!

  def not_found
    raise ActionController::RoutingError.new('Not Found')
  end

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) do |u|
      u.permit :username, :email, :password, :password_confirmation
    end

    devise_parameter_sanitizer.for(:account_update) do |u|
      u.permit(:username, :email, :password, :password_confirmation,
               :current_password)
    end

    devise_parameter_sanitizer.for(:accept_invitation)
      .concat [:first_name, :last_name, :phone]

    devise_parameter_sanitizer.for(:accept_invitation) do |u|
      u.permit(:first_name, :last_name, :phone, :password,
               :password_confirmation, :invitation_token)
    end
  end

  def authorize_admin!
    return true if current_user.admin?
    alert = 'Du hast keine Berechtigung für den Admin Bereich!'
      redirect_to :root, alert: alert and return
  end
end
{'fraction_non_alphanumeric': 0.0814968814968815, 'fraction_numerical': 0.0, 'mean_word_length': 4.394618834080718, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6189415', 'n_tokens_mistral': 748, 'n_tokens_neox': 724, 'n_words': 159}