Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ GEM
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
brakeman (8.0.2)
brakeman (8.0.4)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI was failing because the brakeman version does not match

https://github.com/fastruby/ruby_or_rails/actions/runs/22741750663/job/65956852118

racc
builder (3.3.0)
capybara (3.40.0)
Expand Down
10 changes: 4 additions & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ class ApplicationController < ActionController::Base
private

def check_user_token
unless session[:user_token]
render "puzzles/login"
end
render "puzzles/login" and return unless session[:user_token]
end

def check_session_expiry
if session[:expires_at].present? && Time.current > session[:expires_at]
reset_session
render "puzzles/login"
else
session[:expires_at] = 1.hour.from_now
render "puzzles/login" and return
end

session[:expires_at] = 1.hour.from_now
end
end
6 changes: 6 additions & 0 deletions test/controllers/puzzles_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class PuzzlesControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end

test "unauthenticated request renders login page" do
get puzzles_path
assert_response :success
assert_match "login", response.body.downcase
end

test "should show error message when editing puzzle with invalid data" do
puzzle = puzzles(:one)

Expand Down