Sha256: 838c1e4ae65724dd041e64357ade4ac7d011a3f4331595acc091e2beeacb8f3c

Contents?: true

Size: 686 Bytes

Versions: 7

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

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

    if logged_in?
      redirect_to admin_default_url
    else
      flash[:notice] = "The provided email address and password combination " \
                       "was not valid"
      redirect_to login_admin_users_url
    end
  end

  def destroy
    flash[:notice] = "You have been logged out"
    deauthenticate!
    redirect_to login_admin_users_url
  end

  protected

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pages_core-3.9.2 app/controllers/sessions_controller.rb
pages_core-3.9.1 app/controllers/sessions_controller.rb
pages_core-3.9.0 app/controllers/sessions_controller.rb
pages_core-3.8.3 app/controllers/sessions_controller.rb
pages_core-3.8.2 app/controllers/sessions_controller.rb
pages_core-3.8.1 app/controllers/sessions_controller.rb
pages_core-3.8.0 app/controllers/sessions_controller.rb