Class: SessionsController

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

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, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Instance Method Details

#indexObject


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

def index
  redirect_to action: :login
end

#loginObject


18
19
20
21
22
23
24
25
26
27
28
29
30
# 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
    if params
      flash.now[:error] = "Your log in details don't match our records. Please try again."
    end
  end
end

#logoutObject


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

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


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

def settings
end