Class: Spina::Admin::SessionsController

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

Instance Method Summary collapse

Methods inherited from AdminController

#current_admin_path

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spina/admin/sessions_controller.rb', line 12

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

#destroyObject



24
25
26
27
# File 'app/controllers/spina/admin/sessions_controller.rb', line 24

def destroy
  session[:user_id] = nil
  redirect_to "/"
end

#newObject



9
10
# File 'app/controllers/spina/admin/sessions_controller.rb', line 9

def new
end