Sha256: 623292caba57045751f235c46a1a83ceb4ae6ade3988b463ec89902ac7f9b2cc

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

module Fiona7
  class SessionsController < ActionController::Base
    before_filter :load_login_page

    def create
      login, password = params[:login], params[:password]
      if valid_credentials?(login, password)
        rsession.user_name = login

        redirect_to true_root_path
      else
        flash[:error] = I18n.t(:"fiona7.invalid_credentails")
        begin
          redirect_to :back
        rescue ActionController::RedirectBackError
          redirect_to scrivito_path(@login_page)
        end
      end
    end

    def destroy
      rsession.destroy
      redirect_to true_root_path
    end

    protected
    def load_login_page
      @login_page = Fiona7LoginPage.instance || Scrivito::BasicObj.root
    end

    def true_root_path
      if Fiona7.mode == :standalone
        '/'
      elsif Fiona7.mode == :legacy
        root_path
      else
        raise "Invalid Fiona7.mode = #{Fiona7.mode}"
      end
    end

    def valid_credentials?(login, password)
      Reactor::Sudo.su(Fiona7.root) do
        Reactor::Cm::User.new(login).has_password?(password)
      end
    rescue Reactor::Cm::XmlRequestError => e
      Rails.logger.error("Error logging in: #{e.message}")
      false
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
infopark_fiona7-1.2.0.2.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.5.5.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.5.5.0 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.2.0.1.4 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.5.4.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.5.4.0 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.2.0.1.3 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.5.3.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.4.3.0 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.3.2.0 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.5.2.0.0 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.2.0.1.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.2.0.0.1 app/controllers/fiona7/sessions_controller.rb
infopark_fiona7-1.2.0.0.0 app/controllers/fiona7/sessions_controller.rb