Sha256: e08a806a3937688188183fbd13c7b4d967b34aaf3c04e9cc07ddfe8907d194b7

Contents?: true

Size: 606 Bytes

Versions: 8

Compression:

Stored size: 606 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: password) if email && password
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pages_core-3.12.7 app/controllers/sessions_controller.rb
pages_core-3.12.6 app/controllers/sessions_controller.rb
pages_core-3.12.5 app/controllers/sessions_controller.rb
pages_core-3.12.4 app/controllers/sessions_controller.rb
pages_core-3.12.3 app/controllers/sessions_controller.rb
pages_core-3.12.2 app/controllers/sessions_controller.rb
pages_core-3.12.1 app/controllers/sessions_controller.rb
pages_core-3.12.0 app/controllers/sessions_controller.rb