Class: SessionsController

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

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



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

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



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

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
17
# File 'app/controllers/sessions_controller.rb', line 16

def settings
end