app/controllers/dashboard_controller.rb
# Handle user credentials from login screen
Handle user credentials from login screen
Handle user credentials from login screen
def authenticate
    @layout = "dashboard"
    unless params[:task_id] 
      case params[:button]
      when "more"
        @more = true
        render :update do |page|
          page.replace("login_more_div", :partial => "login_more")
          page << javascript_focus('user_new_password')
          page << javascript_show("back_button")
          page << javascript_hide("more_button")
        end
        return
      when "back"
        render :update do |page|
          page.replace("login_more_div", :partial => "login_more")
          page << javascript_focus('user_name')
          page << javascript_hide("back_button")
          page << javascript_show("more_button")
        end
        return
      end
    end
    user = {
      :name            => params[:user_name],
      :password        => params[:user_password],
      :new_password    => params[:user_new_password],
      :verify_password => params[:user_verify_password]
    }
    if params[:user_name].blank? && params[:user_password].blank? &&
       request.headers["X-Remote-User"].blank? &&
       get_vmdb_config[:authentication][:mode] == "httpd" &&
       get_vmdb_config[:authentication][:sso_enabled] &&
       params[:action] == "authenticate"
      render :update do |page|
        page.redirect_to(root_path)
      end
      return
    end
    validation = validate_user(user, params[:task_id], request)
    case validation.result
    when :wait_for_task
    when :pass
      session['referer'] = request.base_url + '/'
      render :update do |page|
        page.redirect_to(validation.url)
      end
    when :fail
      clear_current_user
      add_flash(validation.flash_msg || _("Error: Authentication failed"), :error)
      render :update do |page|
        page.replace("flash_msg_div", :partial => "layouts/flash_msg")
        page << javascript_show("flash_div")
        page << "miqSparkle(false);"
        page << "miqEnableLoginFields(true);"
      end
    end
  end
def authenticate @layout = "dashboard" unless params [ :task_id ] case params [ :button ] when "more" @more = true render :update do | page | page . replace ( "login_more_div" , :partial => "login_more" ) page << javascript_focus ( 'user_new_password' ) page << javascript_show ( "back_button" ) page << javascript_hide ( "more_button" ) end return when "back" render :update do | page | page . replace ( "login_more_div" , :partial => "login_more" ) page << javascript_focus ( 'user_name' ) page << javascript_hide ( "back_button" ) page << javascript_show ( "more_button" ) end return end end user = { :name => params [ :user_name ] , :password => params [ :user_password ] , :new_password => params [ :user_new_password ] , :verify_password => params [ :user_verify_password ] } if params [ :user_name ] . blank? && params [ :user_password ] . blank? && request . headers [ "X-Remote-User" ] . blank? && get_vmdb_config [ :authentication ] [ :mode ] == "httpd" && get_vmdb_config [ :authentication ] [ :sso_enabled ] && params [ :action ] == "authenticate" render :update do | page | page . redirect_to ( root_path ) end return end validation = validate_user ( user , params [ :task_id ] , request ) case validation . result when :wait_for_task when :pass session [ 'referer' ] = request . base_url + '/' render :update do | page | page . redirect_to ( validation . url ) end when :fail clear_current_user add_flash ( validation . flash_msg || _ ( "Error: Authentication failed" ) , :error ) render :update do | page | page . replace ( "flash_msg_div" , :partial => "layouts/flash_msg" ) page << javascript_show ( "flash_div" ) page << "miqSparkle(false);" page << "miqEnableLoginFields(true);" end end end
Handle user credentials from login screen
Handle user credentials from login screen
# First time thru, check for buttons pressed # Handle More and Back buttons (for changing password) # noop, page content already set by initiate_wait_for_task