Skip to content

Commit 3470615

Browse files
committed
gracefully handle invalid sessions
1 parent bda3e37 commit 3470615

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/controllers/application_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ def clear_expired_cookie_if_session_is_empty
4141

4242
def current_user
4343
if @current_user.nil? && session[:current_user]
44-
@current_user = User.find(session[:current_user])
44+
unless @current_user = User.find_by_id(session[:current_user])
45+
session[:current_user] = nil
46+
store_location!
47+
redirect_to signin_path
48+
end
4549
end
50+
4651
@current_user
4752
end
4853

0 commit comments

Comments
 (0)