Class: SessionsController

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

Overview

Handles log in / log out

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/sessions_controller.rb', line 7

def create
  self.user_swipecard = params.require(:user_swipecard)
  if @current_user
    redirect_to :search, notice: 'Logged in' # rubocop:todo Rails/I18nLocaleTexts
  else
    redirect_to :search,
                alert: 'Sorry, that swipecard could not be found. Please update your details in Sequencescape.' # rubocop:todo Rails/I18nLocaleTexts
  end
end

#destroyObject



17
18
19
20
21
22
# File 'app/controllers/sessions_controller.rb', line 17

def destroy
  reset_session
  cookies[:user_name] = nil
  cookies[:user_id] = nil
  redirect_to :search, notice: 'Logged out' # rubocop:todo Rails/I18nLocaleTexts
end