Class: Admin::SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/admin/sessions_controller.rb', line 10

def create
  admin = admins_repository.find(email: create_params[:email])

  if admin && admin.correct_password?(create_params[:password])
    create_admin_session(admin)
    redirect_to (locale)
  else
    render :new, locals: { admin: admins_repository.new }
  end
end

#destroyObject



21
22
23
24
# File 'app/controllers/admin/sessions_controller.rb', line 21

def destroy
  destroy_admin_session
  redirect_to after_logout_path(locale)
end

#newObject



2
3
4
5
6
7
8
# File 'app/controllers/admin/sessions_controller.rb', line 2

def new
  if current_admin
    redirect_to (locale)
  else
    render :new, locals: { admin: admins_repository.new }
  end
end