Skip to content

Commit ea1fde0

Browse files
committed
compound statement
1 parent ebb77fc commit ea1fde0

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

lib/zendesk_api/middleware/request/api_token_impersonate.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@ def call(env)
1212
if Thread.current[:zendesk_thread_local_username] && env[:request_headers][:authorization] =~ /^Basic /
1313
current_u_p_encoded = env[:request_headers][:authorization].split(/\s+/)[1]
1414
current_u_p = Base64.urlsafe_decode64(current_u_p_encoded)
15-
unless current_u_p.include?("/token:")
16-
warn "WARNING: ApiTokenImpersonate passed in invalid format. It should be in the format username/token:APITOKEN"
17-
return @app.call(env)
18-
end
19-
20-
parts = current_u_p.split(":")
21-
22-
unless parts.length == 2 && parts[0].include?("/token")
15+
unless current_u_p.include?("/token:") && (parts = current_u_p.split(":")) && parts.length == 2 && parts[0].include?("/token")
2316
warn "WARNING: ApiTokenImpersonate passed in invalid format. It should be in the format username/token:APITOKEN"
2417
return @app.call(env)
2518
end

0 commit comments

Comments
 (0)