Completed
Push — master ( 076eda...79da31 )
by
unknown
11s
created

UserSessionsController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A destroy() 0 6 1
A new() 0 3 1
A participant_session_params() 0 3 1
A create() 0 10 2
1
class UserSessionsController < ApplicationController
2
  def new
3
    @participant_session = ParticipantSession.new
4
  end
5
6
  def create
7
    @participant_session = ParticipantSession.new(participant_session_params)
8
    if @participant_session.save
9
      flash[:notice] = "You're logged in. Welcome back."
10
      redirect_to root_path
11
    else
12
      flash.now[:error] = "Sorry, couldn't find that participant. Try again, or sign up to register a new account."
13
      render :action => :new
14
    end
15
  end
16
17
  def destroy
18
    current_participant_session.destroy
19
20
    flash[:notice] = 'You have been logged out.'
21
    redirect_to root_path
22
  end
23
24
   private
25
26
  def participant_session_params
27
    params.require(:participant_session).permit(:email, :password)
28
  end
29
30
end
31