Sha256: e66e9cc974231d742fddd073616a24b9d15fae45a636c9088b10d5be941b7dcf

Contents?: true

Size: 1.86 KB

Versions: 14

Compression:

Stored size: 1.86 KB

Contents

module IshManager
  class ApplicationController < ActionController::Base
    protect_from_forgery :with => :exception, :prepend => true
    before_action :set_current_ability
    before_action :set_changelog
    check_authorization
    rescue_from ::CanCan::AccessDenied, :with => :access_denied

    def home
      authorize! :home, IshManager::Ability
      render 'home'
    end

    #
    # private
    #
    private

    def access_denied exception
      store_location_for :user, request.path
      redirect_to user_signed_in? ? root_path : Rails.application.routes.url_helpers.new_user_session_path, :alert => exception.message
    end

    def set_changelog
      @version = Gem.loaded_specs['ish_manager'].version.to_s
    end

    def set_current_ability
      if !current_user
        raise ::CanCan::AccessDenied
      end
      @current_profile ||= ::Ish::UserProfile.find_by({ email: current_user.email })
      @current_ability ||= ::IshManager::Ability.new( @current_profile )
    end

    def set_lists
      @galleries_list = Gallery.all.list
      @locations_list = ::Gameui::Map.list
      @maps_list = ::Gameui::Map.list # @TODO: missing nonpublic!
      @reports_list = Report.all.list
      @user_profiles_list = Ish::UserProfile.list
      @videos_list = Video.all.list
    end

    def pp_errors err
      err
    end

    def puts! a, b=''
      puts "+++ +++ #{b}"
      puts a.inspect
    end

    # @TODO: obsolete, remove _vp_ 2022-10-15
    def update_profile_pic
      return unless params[:photo]
      @photo = Photo.new :photo => params[:photo]
      @photo.user_profile = @current_profile
      flag = @photo.save
      @resource.profile_photo = @photo
      flagg = @resource.save
      if flag && flagg
        flash[:notice] = 'Success'
      else
        flash[:alert] = "No Luck. #{@photo.errors.messages} #{@resource.errors.messages}"
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ish_manager-0.1.8.353 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.352 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.351 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.350 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.349 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.348 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.347 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.346 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.345 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.344 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.343 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.342 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.341 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.340 app/controllers/ish_manager/application_controller.rb