Sha256: e2be7db44d966e638f0cf17f2715358832c642f0d0712cbf91c3e88fd29446ba

Contents?: true

Size: 832 Bytes

Versions: 29

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

module SlashAdmin
  module Security
    class SessionsController < ActionController::Base
      protect_from_forgery with: :exception

      layout "slash_admin/admin_user"

      def new
      end

      def create
        admin = Admin.where("username = :value OR lower(email) = lower(:value)", value: params[:admin][:login]).first
        if admin&.authenticate(params[:admin][:password])
          session[:admin_id] = admin.id
          flash[:success] = "Vous êtes à présent connecté."
          redirect_to slash_admin.dashboard_path
        else
          @error_messages = "Merci de vérifier vos identifiants"
          render(:new) && return
        end
      end

      def destroy
        session[:admin_id] = nil
        redirect_to slash_admin.login_url
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
slash_admin-1.5.11 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.10 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.9 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.8 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.7 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.6 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.5 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.4 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.3 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.2 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5.1 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.5 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.4.1 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.4 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.5 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.4 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.3 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.2 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.1 app/controllers/slash_admin/security/sessions_controller.rb
slash_admin-1.3.0 app/controllers/slash_admin/security/sessions_controller.rb