Skip to content

Commit ee5cd6f

Browse files
committed
Simplify the authentication concern
Explaining method was left explaining nothing and the conditional guard wasnt necessary either (since Current.session should already be nil anyway by this point!)
1 parent a3a05a9 commit ee5cd6f

File tree

1 file changed

+2
-8
lines changed
  • railties/lib/rails/generators/rails/authentication/templates/controllers/concerns

1 file changed

+2
-8
lines changed

railties/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def require_authentication
2323

2424

2525
def resume_session
26-
if session = find_session_by_cookie
27-
set_current_session session
28-
end
26+
Current.session = find_session_by_cookie
2927
end
3028

3129
def find_session_by_cookie
@@ -45,15 +43,11 @@ def after_authentication_url
4543

4644
def start_new_session_for(user)
4745
user.sessions.create!(user_agent: request.user_agent, ip_address: request.remote_ip).tap do |session|
48-
set_current_session session
46+
Current.session = session
4947
cookies.signed.permanent[:session_id] = { value: session.id, httponly: true, same_site: :lax }
5048
end
5149
end
5250

53-
def set_current_session(session)
54-
Current.session = session
55-
end
56-
5751
def terminate_session
5852
Current.session.destroy
5953
cookies.delete(:session_id)

0 commit comments

Comments
 (0)