Sha256: 2cdb3265d57df8c3805c4575c4bc19282adc319d788074d950bfc72f3e25ac55

Contents?: true

Size: 597 Bytes

Versions: 5

Compression:

Stored size: 597 Bytes

Contents

class SessionsController < ApplicationController
  allow_unauthenticated_access only: %i[ new create ]
  rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }

  def new
  end

  def create
    if user = User.authenticate_by(params.permit(:email_address, :password))
      start_new_session_for user
      redirect_to after_authentication_url
    else
      redirect_to new_session_path, alert: "Try another email address or password."
    end
  end

  def destroy
    terminate_session
    redirect_to new_session_path
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
tm_lyn-0.1.0 app/controllers/sessions_controller.rb
railties-8.0.1 lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt
railties-8.0.0.1 lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt
railties-8.0.0 lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt
railties-8.0.0.rc2 lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt