Class: Tienda::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tienda/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/tienda/sessions_controller.rb', line 7

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

#destroyObject



17
18
19
20
# File 'app/controllers/tienda/sessions_controller.rb', line 17

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

#resetObject



22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/tienda/sessions_controller.rb', line 22

def reset

  if request.post?
    if user = Tienda::User.find_by_email_address(params[:email_address])
      user.reset_password!
      redirect_to (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