Sha256: 4ff3b0de69d7f1d4cbf07161ed4cc2892dfe886a91b5b9f71783674b08fa4152

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true
module SlashAdmin
  class Security::SessionsController < ActionController::Base
    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[:notice] = 'Vous êtes à présent connecté.'
        redirect_to slash_admin.dashboard_path
      else
        @error_messages = 'Merci de vérifier vos identifiants'
        render :new and return
      end
    end

    def destroy
      session[:admin_id] = nil
      flash[:notice] = 'Déconnecté avec succès.'
      redirect_to slash_admin.login_url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slash_admin-0.1.0 lib/generators/slash_admin/override_session/templates/session.erb