Class: SessionsController

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

Overview

rubocop:todo Style/Documentation

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods included from Informatics::Globals

#application, #application=, #defaults, #defaults=, #global_searchable_classes, #search_options

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#indexObject


12
13
14
# File 'app/controllers/sessions_controller.rb', line 12

def index
  redirect_to action: :login
end

#loginObject


18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/sessions_controller.rb', line 18

def 
  return unless request.post?

  self.current_user = User.authenticate(params[:login], params[:password])
  if logged_in?
    flash[:notice] = 'Logged in successfully'
    redirect_back_or_default(controller: :studies)
  else
    flash.now[:error] = "Your log in details don't match our records. Please try again." if params
  end
end

#logoutObject


30
31
32
33
34
35
36
# File 'app/controllers/sessions_controller.rb', line 30

def logout
  current_user.forget_me if logged_in?
  cookies.delete :auth_token
  reset_session
  flash[:notice] = 'You have been logged out.'
  redirect_back_or_default(controller: :studies)
end

#settingsObject


16
# File 'app/controllers/sessions_controller.rb', line 16

def settings; end