mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
Handle API key in endpoint
This commit is contained in:
parent
0d26dc587f
commit
7f79029250
1 changed files with 4 additions and 2 deletions
|
|
@ -18,7 +18,9 @@ class Api::V1::StatsController < ApplicationController
|
|||
private
|
||||
|
||||
def ensure_authenticated!
|
||||
bearer_token = request.headers["Authorization"].split(" ").last
|
||||
return render json: { error: "Unauthorized" }, status: :unauthorized unless bearer_token == ENV["STATS_API_KEY"]
|
||||
token = request.headers["Authorization"]&.split(" ")&.last
|
||||
token ||= params[:api_key]
|
||||
|
||||
return render plain: "Unauthorized", status: :unauthorized unless token == ENV["STATS_API_KEY"]
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue