Sha256: 35932b1edf20448aadb2ef6b32664c6f32e77494e3ab1020b93c3aa9f31d37a5

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

module Spina
  module Admin
    class SessionsController < AdminController
      skip_before_action :authorize_spina_user

      def new
      end

      def create
        user = User.where(email: params[:email]).first
        if user && user.authenticate(params[:password])
          session[:spina_user_id] = user.id
          user.touch(:last_logged_in)
          redirect_to spina.admin_root_url
        else
          flash.now[:alert] = I18n.t('spina.notifications.wrong_username_or_password')
          render "new", status: :unprocessable_entity
        end
      end

      def destroy
        session.delete(:spina_user_id)
        redirect_to "/"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spina-2.1.1 app/controllers/spina/admin/sessions_controller.rb
spina-2.1.0 app/controllers/spina/admin/sessions_controller.rb