# frozen_string_literal: true # Forma de ingreso a Sutty class ApplicationController < ActionController::Base include ExceptionHandler protect_from_forgery with: :exception before_action :configure_permitted_parameters, if: :devise_controller? around_action :set_locale before_action do if current_usuarie.try(:ends_with?, '@' + ENV.fetch('SUTTY', 'sutty.nl')) Rack::MiniProfiler.authorize_request end end # No tenemos índice de sutty, vamos directamente a ver el listado de # sitios def index redirect_to sites_path end def markdown; end private # Encontrar un sitio por su nombre def find_site id = params[:site_id] || params[:id] unless (site = current_usuarie.sites.find_by_name(id)) raise SiteNotFound end site end # El idioma es el preferido por le usuarie, pero no necesariamente se # corresponde con el idioma de los artículos, porque puede querer # traducirlos. def set_locale(&action) I18n.with_locale(current_usuarie.try(:lang) || I18n.default_locale, &action) end protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:account_update, keys: %i[lang]) end end