Sha256: 02255bc0e2d39112adbb9697576c340a6fecd76272d2a78c5c5741f87f9e296b

Contents?: true

Size: 1.11 KB

Versions: 43

Compression:

Stored size: 1.11 KB

Contents

class Admin::WelcomeController < ApplicationController
  no_login_required
  before_action :never_cache
  skip_before_action :verify_authenticity_token

  def index
    redirect_to admin_pages_path
  end

  def login
    if request.post?
      @username_or_email = params[:username_or_email]
      password = params[:password]
      announce_invalid_user unless self.current_user = User.authenticate(@username_or_email, password)
    end
    if current_user
      if params[:remember_me]
        current_user.remember_me
        set_session_cookie
      end
      redirect_to(session[:return_to] || welcome_path)
      session[:return_to] = nil
    end
  end

  def logout
    request.cookies[:session_token] = { :expires => 1.day.ago.utc }
    self.current_user.forget_me if self.current_user
    self.current_user = nil
    announce_logged_out
    redirect_to login_path
  end

  private

    def never_cache
      expires_now
    end

    def announce_logged_out
      flash[:notice] = t('welcome_controller.logged_out')
    end

    def announce_invalid_user
      flash.now[:error] = t('welcome_controller.invalid_user')
    end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
trusty-cms-3.7.1 app/controllers/admin/welcome_controller.rb
trusty-cms-3.7.0 app/controllers/admin/welcome_controller.rb
trusty-cms-3.6.2 app/controllers/admin/welcome_controller.rb
trusty-cms-3.6.1 app/controllers/admin/welcome_controller.rb
trusty-cms-3.6.0 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.5 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.4 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.3 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.2 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.1 app/controllers/admin/welcome_controller.rb
trusty-cms-3.5.0 app/controllers/admin/welcome_controller.rb
trusty-cms-3.4.0 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.7 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.6 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.5 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.3 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.2 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.1 app/controllers/admin/welcome_controller.rb
trusty-cms-3.2.1 app/controllers/admin/welcome_controller.rb
trusty-cms-3.3.0 app/controllers/admin/welcome_controller.rb