Sha256: 077fc8430bb12147b59eb4760bf414f82ac41f0d8e9fc71969db10993854b9df

Contents?: true

Size: 1004 Bytes

Versions: 3

Compression:

Stored size: 1004 Bytes

Contents

class Admin::WelcomeController < ApplicationController
  no_login_required
  skip_before_filter :verify_authenticity_token
  
  def index
    redirect_to admin_pages_url
  end
  
  def login
    if request.post?
      login = params[:user][:login]
      password = params[:user][:password]
      announce_invalid_user unless self.current_user = User.authenticate(login, password)
    end
    if current_user
      if params[:remember_me]
        current_user.remember_me
        set_session_cookie
      end
      redirect_to (session[:return_to] || welcome_url)
      session[:return_to] = nil
    end
  end
  
  def logout
    cookies[:session_token] = { :expires => 1.day.ago }
    self.current_user.forget_me
    self.current_user = nil
    announce_logged_out
    redirect_to login_url
  end
  
  private
  
    def announce_logged_out
      flash[:notice] = 'You are now logged out.'
    end
    
    def announce_invalid_user
      flash[:error] = 'Invalid username or password.'
    end
    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.7.2 app/controllers/admin/welcome_controller.rb
radiant-0.7.0 app/controllers/admin/welcome_controller.rb
radiant-0.7.1 app/controllers/admin/welcome_controller.rb