verificar la transacción guardada
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
9eab5ca0f6
commit
b79c954d3b
2 changed files with 3 additions and 3 deletions
|
@ -16,7 +16,7 @@ class ReadingsController < ActionController::API
|
||||||
reading.id = params[:transaction_uuid]
|
reading.id = params[:transaction_uuid]
|
||||||
reading.signature = request.headers[:'X-Signature']
|
reading.signature = request.headers[:'X-Signature']
|
||||||
reading.raw_transaction = request.raw_post
|
reading.raw_transaction = request.raw_post
|
||||||
reading.verified = reading.verify
|
reading.verified = reading.verify_ssh_signature
|
||||||
|
|
||||||
params[:arduinos]&.each do |a|
|
params[:arduinos]&.each do |a|
|
||||||
arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry
|
arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry
|
||||||
|
|
|
@ -4,8 +4,8 @@ class Reading < ApplicationRecord
|
||||||
belongs_to :raspberry
|
belongs_to :raspberry
|
||||||
has_many :arduinos
|
has_many :arduinos
|
||||||
|
|
||||||
def verify
|
def verify_ssh_signature
|
||||||
ssh_signature.verify transaction
|
ssh_signature.verify raw_transaction
|
||||||
rescue SSHData::Error
|
rescue SSHData::Error
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue