Sha256: cc23f9180bb11276436e9da105ade8048b25c131c23cdb9a92dfcdae16070f35

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module Shoppe
  class SessionsController < Shoppe::ApplicationController

    layout 'shoppe/sub'
    skip_before_filter :login_required, :only => [:new, :create, :reset]
  
    def create
      if user = Shoppe::User.authenticate(params[:email_address], params[:password])
        session[:shoppe_user_id] = user.id
        redirect_to :orders
      else
        flash.now[:alert] = "The email address and/or password you have entered is invalid. Please check and try again."
        render :action => "new"
      end
    end
  
    def destroy
      session[:shoppe_user_id] = nil
      redirect_to :login
    end
  
    def reset
    
      if request.post?
        if user = Shoppe::User.find_by_email_address(params[:email_address])
          user.reset_password!
          redirect_to login_path(:email_address => params[:email_address]), :notice => "An e-mail has been sent to #{user.email_address} with a new password"
        else
          flash.now[:alert] = "No user was found matching the e-mail address"
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shoppe-1.0.2 app/controllers/shoppe/sessions_controller.rb
shoppe-1.0.1 app/controllers/shoppe/sessions_controller.rb
shoppe-1.0.0 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.21 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.20 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.19 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.18 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.17 app/controllers/shoppe/sessions_controller.rb
shoppe-0.0.16 app/controllers/shoppe/sessions_controller.rb