Sha256: 7ce05feac2708ce79cc35a9fd716f7e7ee9516e3115dbfa53dcb8b9efa9bd7aa

Contents?: true

Size: 843 Bytes

Versions: 25

Compression:

Stored size: 843 Bytes

Contents

class User::SessionsController < ApplicationController
  def new
    if params[:event] == 'confirmed'
      flash.now[:notice] = 'Your account has been verified. You can sign in now.'
    end
    render
  end

  def create
    user = User.find_by email: params[:email]
    auth_failed && return if user.nil?
    auth_failed('Your account is waiting for confirmation.') && return if not user.confirmed?
    auth_failed && return if not user.authenticate params[:password]
    cookies.signed[:user_id] = user.id
    redirect_to user_root_url, notice: 'Successfully signed in.'
  end

  def destroy
    cookies.signed[:user_id] = nil
    redirect_to new_user_session_url, notice: 'Successfully signed out.'
  end

  private

    def auth_failed alert = 'Invalid email or password.'
      redirect_to new_user_session_url, alert: alert
    end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
loco-rails-3.0.5 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-3.0.4 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-3.0.3 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.5.3 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.5.2 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-3.0.2 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-3.0.1 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.5.1 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.5.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.4.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.3.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-3.0.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.2.2 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.2.1 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.2.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.1.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-2.0.0 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-1.5.2 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-1.5.1 test/dummy/app/controllers/user/sessions_controller.rb
loco-rails-1.5.0 test/dummy/app/controllers/user/sessions_controller.rb