Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |