Class: SessionsController

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

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) create

POST /sessions



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/sessions_controller.rb', line 8

def create
  user = User.find_by(email: params[:session][:email].downcase)
  if user && user.authenticate(params[:session][:password]) 
    
    unless user.is_flagged_for_password_reset?
      (user, request)
      redirect_to root_path
    else
      @user = user
      render 'request_password_reset'
    end
  else
    @page_title = 'Sign in'
    flash.now[:error] = 'Unrecognised email and password combination.'
    render 'new'
  end
end

- (Object) destroy

DELETE /signout



27
28
29
30
# File 'app/controllers/sessions_controller.rb', line 27

def destroy
  sessions_sign_out
  redirect_to root_url
end

- (Object) new

GET /signin



4
5
# File 'app/controllers/sessions_controller.rb', line 4

def new
end