Class: Plum::SessionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Plum::SessionsController
- Defined in:
- app/controllers/plum/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/plum/sessions_controller.rb', line 9 def create user = Plum::User.find_by(email: params[:email]) if user&.authenticate(params[:password]) session[:plum_user_id] = user.id redirect_to cp_root_path, notice: "Welcome back!" else flash.now[:alert] = "Invalid email or password" render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
20 21 22 23 |
# File 'app/controllers/plum/sessions_controller.rb', line 20 def destroy session[:plum_user_id] = nil redirect_to login_path, notice: "You have been logged out" end |
#new ⇒ Object
5 6 7 |
# File 'app/controllers/plum/sessions_controller.rb', line 5 def new redirect_to cp_root_path if logged_in? end |