Sha256: 048e7d9534f03c1864f59c4f77c0ca1069ccfb2bcd0ce5b9b99489941f9b8f9c
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
class FlyAdmin::Imbs::ApplicationController < ActionController::Base protect_from_forgery before_filter :block_user, :store_link_param before_filter :check_user_status, if: Proc.new { user_signed_in? && old_user? }, unless: :devise_controller? before_filter :set_locale, :load_footer def block_user render_blocked if session[:blocked] end def store_link_param session[:link] = params[:link] if params[:link].present? end def check_user_status user_is_valid = FlyAdmin::Imbs::ConnectionApi.check_user(current_user) if user_is_valid current_user.update_attributes is_active: true cookies[:active_user] = { value: 1, expires: 1.day.from_now } else current_user.update_attributes is_active: false session[:blocked] = true render_blocked end end def load_footer paysite = session['action_type'] || 'wap' country = I18n.locale.to_s @footer = SiteCache.read("content_#{paysite}_#{country}") end private def old_user? !(current_user.admin? || current_user.tester? || cookies[:active_user].present?) end def set_locale locale = params["locale"].try(:downcase).try(:to_sym) I18n.locale = locale && I18n.available_locales.include?(params) ? locale : I18n.default_locale end # Locale for all url_helpers in rails def default_url_options(options = {}) { locale: I18n.locale }.merge options end def after_sign_in_path_for(resource) root_url end def after_sign_out_path_for(resource) root_url end def render_blocked render 'errors/blocked', status: :forbidden end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fly_admin-0.0.7 | app/controllers/fly_admin/imbs/application_controller.rb |
fly_admin-0.0.6 | app/controllers/fly_admin/imbs/application_controller.rb |