Skip to content

Commit

Permalink
redirection (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
vswamidass-sfdc authored Oct 24, 2024
1 parent 91b22ca commit 467f020
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

class SessionsController < ApplicationController
skip_before_action :require_login

Expand All @@ -9,27 +7,27 @@ def create
user = User.find_by_email(params[:session][:email])
if user&.authenticate(params[:session][:password])
login_user(user)
redirect_to root_path
redirect_back(fallback_location: root_path)
else
redirect_to new_session_url, notice: 'Error logging in.'
end
end

def set_debug
session[:debug] = params[:debug]
redirect_to root_url, notice: "Debug mode: #{session[:debug]}"
redirect_back(fallback_location: root_url, notice: "Debug mode: #{session[:debug]}")
end

def set_beta
session[:beta] = params[:beta]
redirect_to root_url, notice: "Beta mode: #{session[:beta]}"
redirect_back(fallback_location: root_url, notice: "Beta mode: #{session[:beta]}")
end

def logout
Rails.logger.debug "Session before Logout: #{session.to_hash}"
Rails.logger.info "Logout called: #{request.referrer}, #{request.user_agent}, #{request.remote_ip}, #{session.to_hash}"

session[:user_id] = nil
redirect_to root_url
redirect_back(fallback_location: root_url)
end
end

0 comments on commit 467f020

Please sign in to comment.