14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/passkit/api/v1/passes_controller.rb', line 14
def show
authentication_token = request.["Authorization"]&.split(" ")&.last
unless authentication_token.present?
render json: {}, status: :unauthorized
return
end
pass = Pass.find_by(serial_number: params[:serial_number], authentication_token: authentication_token)
unless pass
render json: {}, status: :unauthorized
return
end
pass_output_path = Passkit::Generator.new(pass).generate_and_sign
response.["last-modified"] = pass.last_update.httpdate
if request.["If-Modified-Since"].nil? ||
(pass.last_update.to_i > Time.zone.parse(request.["If-Modified-Since"]).to_i)
send_file(pass_output_path, type: "application/vnd.apple.pkpass", disposition: "attachment")
else
head :not_modified
end
end
|