Sha256: 037cef5772071b4545d6168d0b4935dc19715e6d4d889787d37b657903444607
Contents?: true
Size: 1.39 KB
Versions: 4
Compression:
Stored size: 1.39 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 login_redirect 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 begin redirect_to :back rescue ActionController::RedirectBackError redirect_to true_root_path end end protected def load_login_page @login_page = Fiona7LoginPage.instance || Scrivito::BasicObj.root end def login_redirect session[:login_redirect].presence || true_root_path 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
4 entries across 4 versions & 1 rubygems