Sha256: 99f80dc270d4a028c6d6608cacdf53c110c3d4ca387d0b80506fe4d8e75b603d

Contents?: true

Size: 597 Bytes

Versions: 1

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

class SessionsController < ApplicationController
  def create
    user = find_user(params[:email], params[:password])
    authenticate!(user) if user

    if logged_in?
      redirect_to admin_default_url
    else
      flash[:notice] = t("pages_core.invalid_login")
      redirect_to login_admin_users_url
    end
  end

  def destroy
    flash[:notice] = t("pages_core.logged_out")
    deauthenticate!
    redirect_to login_admin_users_url
  end

  protected

  def find_user(email, password)
    User.authenticate(email, password:) if email && password
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.13.0 app/controllers/sessions_controller.rb