Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirection #90

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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