Class: Admin::SessionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user, #load_settings

Instance Method Details

#createObject


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

def create
  if @user && @user.authenticate(params[:password])
    session[:user_id] = @user.id
    redirect_to admin_root_path, notice: 'Log in successful!'
  else
    flash.now.alert = 'Invalid email or password.'
    render :new
  end
end

#destroyObject


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

def destroy
  session[:user_id] = nil
  redirect_to root_path
end

#newObject


7
8
# File 'app/controllers/admin/sessions_controller.rb', line 7

def new
end