- Implement remember me checkbox in login form - Update sessions controller to handle remember me logic - Enhance session management to prevent session hijacking - Add tests for remember me functionality This commit introduces a "Remember me" feature that allows users to stay logged in across sessions. It includes updates to the login form, session handling in the controller, and additional tests to ensure the functionality works as expected. The changes also improve security by validating session tokens to prevent session hijacking.
33 lines
862 B
Ruby
33 lines
862 B
Ruby
ENV["RAILS_ENV"] ||= "test"
|
|
require_relative "../config/environment"
|
|
require "rails/test_help"
|
|
require "minitest/reporters"
|
|
Minitest::Reporters.use!
|
|
|
|
module ActiveSupport
|
|
class TestCase
|
|
# Run tests in parallel with specified workers
|
|
parallelize(workers: :number_of_processors)
|
|
|
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
fixtures :all
|
|
include ApplicationHelper
|
|
|
|
def is_logged_in?
|
|
!session[:user_id].nil?
|
|
end
|
|
|
|
# def log_in_as(user)
|
|
# session[:user_id] = user.id
|
|
# end
|
|
end
|
|
|
|
class ActionDispatch::IntegrationTest
|
|
def log_in_as(user, password: 'password', remember_me: '1')
|
|
post login_path, params: { session: { email: user.email,
|
|
password: password,
|
|
remember_me: remember_me } }
|
|
end
|
|
end
|
|
end
|