Sha256: b0f91414da33b12d1637e19a990f66f0e5d5d65814d491532d3a25ea22ffe894

Contents?: true

Size: 958 Bytes

Versions: 6

Compression:

Stored size: 958 Bytes

Contents

module Tienda
  class SessionsController < Tienda::ApplicationController

    layout 'tienda/sub'
    skip_before_filter :login_required, only: [:new, :create, :reset]

    def create
      if user = Tienda::User.authenticate(params[:email_address], params[:password])
        session[:tienda_user_id] = user.id
        redirect_to :root
      else
        flash.now[:alert] = t('tienda.sessions.create_alert')
        render action: "new"
      end
    end

    def destroy
      session[:tienda_user_id] = nil
      redirect_to :login
    end

    def reset

      if request.post?
        if user = Tienda::User.find_by_email_address(params[:email_address])
          user.reset_password!
          redirect_to login_path(email_address: params[:email_address]), notice: t('tienda.sessions.reset_notice', email_address: user.email_address)
        else
          flash.now[:alert] = t('tienda.sessions.reset_alert')
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tienda-2.1.3 app/controllers/tienda/sessions_controller.rb
tienda-2.1.2 app/controllers/tienda/sessions_controller.rb
tienda-2.1.1 app/controllers/tienda/sessions_controller.rb
tienda-2.1.0 app/controllers/tienda/sessions_controller.rb
tienda-2.0.2 app/controllers/tienda/sessions_controller.rb
tienda-2.0.1 app/controllers/tienda/sessions_controller.rb