Skip to content

Commit 729efb6

Browse files
committed
fix: adjust cookie function name to clarify purpose
1 parent fa0fb45 commit 729efb6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/api/authentication_api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class AuthenticationApi < Grape::API
8080
# Return user details
8181
present :user, user, with: Entities::UserEntity
8282
present :auth_token, token.authentication_token
83-
add_refresh_cookie_to_response(remember)
83+
set_refresh_cookie_in_response(remember)
8484
end
8585
end
8686

@@ -278,7 +278,7 @@ class AuthenticationApi < Grape::API
278278
# Respond user details with new auth token
279279
present :user, user, with: Entities::UserEntity
280280
present :auth_token, token.authentication_token
281-
add_refresh_cookie_to_response(params[:remember])
281+
set_refresh_cookie_in_response(params[:remember])
282282
end
283283
end
284284
end
@@ -360,7 +360,7 @@ class AuthenticationApi < Grape::API
360360
end
361361

362362
# Remove the refresh token cookie - if remember is false
363-
add_refresh_cookie_to_response(false) if params[:remember]
363+
set_refresh_cookie_in_response(false) unless params[:remember]
364364
present nil
365365
end
366366

app/helpers/authentication_helpers.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def authenticated_via_refresh_token?
6262
true
6363
when :token_expired, :error, :missing_details
6464
# Token expired - remove cookies
65-
add_refresh_cookie_to_response(false)
65+
set_refresh_cookie_in_response(false)
6666
false
6767
end
6868
end
@@ -205,7 +205,10 @@ def db_auth?
205205
Doubtfire::Application.config.auth_method == :database
206206
end
207207

208-
def add_refresh_cookie_to_response(remember)
208+
# rubocop:disable Naming/AccessorMethodName
209+
def set_refresh_cookie_in_response(remember)
210+
# rubocop:enable Naming/AccessorMethodName
211+
209212
if remember
210213
token = current_user.auth_tokens.where(token_type: :refresh_token).last
211214

0 commit comments

Comments
 (0)