Class: SessionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SessionsController
- Defined in:
- lib/templates/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/templates/sessions_controller.rb', line 5 def create user = User.where(email: params[:user][:email]).first if params[:user] if user && params[:user] && user.authenticate(params[:user][:password]) flash.clear session[:user_id] = user.id after_sign_in else flash[:error] = "Invalid email / password combination" render :new end end |
#destroy ⇒ Object
17 18 19 20 21 |
# File 'lib/templates/sessions_controller.rb', line 17 def destroy session[:user_id] flash[:success] = 'You have been logged out' redirect_to after_sign_out end |
#new ⇒ Object
2 3 |
# File 'lib/templates/sessions_controller.rb', line 2 def new end |