Skip to content

Commit

Permalink
Fix Reject Bug (#175)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Bengfort <[email protected]>
Co-authored-by: Danielle <[email protected]>
  • Loading branch information
bbengfort and daniellemaxwell authored Jul 24, 2024
1 parent c2dca3b commit 6608331
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 7 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ TRISA_NODE_DIRECTORY_ENDPOINT=localhost:4433
TRISA_NODE_DIRECTORY_MEMBERS_ENDPOINT=localhost:4435

TRISA_DIRECTORY_SYNC_ENABLED=false
TRISA_DIRECTORY_SYNC_INTERVAL="1h"
TRISA_DIRECTORY_SYNC_INTERVAL="1h"

TRISA_TRP_ENABLED=true
TRISA_TRP_BIND_ADDR=:8200
TRISA_TRP_USE_MTLS=false
TRISA_TRP_POOL=.secret/localhost.pem.gz
TRISA_TRP_CERTS=.secret/server.pem.gz
12 changes: 5 additions & 7 deletions pkg/web/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,17 +577,15 @@ func (s *Server) RejectTransaction(c *gin.Context) {
return
}

detailURL, _ := url.JoinPath("/transactions", transaction.ID.String(), "info")
// Set a cookie to show a toast message on the page redirect.
setToastCookie(c, "transaction_reject_success", "true", detailURL, s.conf.Web.Auth.CookieDomain)

// If the content requested is HTML (e.g. the web-front end), then redirect the user
// to the transaction detail page.
// If the content requested is HTML (e.g. the web-front end), then
// respond with a 204 no content response and the front-end will handle the
// success message in the toast.
if c.NegotiateFormat(binding.MIMEJSON, binding.MIMEHTML) == binding.MIMEHTML {
htmx.Redirect(c, http.StatusFound, detailURL)
c.Status(http.StatusNoContent)
return
}

// Otherwise provide the response envelope back to the API client
// Retrieve the secure envelope model for the incoming envelope
if incoming, err = s.store.LatestSecureEnvelope(ctx, transaction.ID, models.DirectionIncoming); err != nil {
c.Error(fmt.Errorf("could not retrieve incoming secure envelope: %w", err))
Expand Down
6 changes: 4 additions & 2 deletions pkg/web/trisa.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ func (s *Server) SendEnvelope(ctx context.Context, outgoing *envelope.Envelope,

// Update the cryptography on the outgoing message for storage (it needs to be
// stored with local keys since it was encrypted for the recipient).
if err = storeOutgoing.Reseal(storageKey, outgoing.Crypto()); err != nil {
return fmt.Errorf("could not encrypt outgoing message for storage: %w", err)
if !storeOutgoing.IsError {
if err = storeOutgoing.Reseal(storageKey, outgoing.Crypto()); err != nil {
return fmt.Errorf("could not encrypt outgoing message for storage: %w", err)
}
}

// Save the outgoing envelope to the database
Expand Down

0 comments on commit 6608331

Please sign in to comment.