[resolved] Decrypt multiple inputs by user on GET request

Options
I'm building an app where users can submit journal entries. Each entry can have up to 3 inputs. I have it set so that entries are encrypted in the back end so that I (or anyone else) can't read them. The encrypted POST is working well (screenshot below) and passes the encrypted data into Xano perfectly.
[Screenshot 2021-11-13 at 15.28.43.png]
What I want to build is a GET api that fetches a logged-in users entries and decrypts them so that a user can look over what they have written. I have an api and endpoint setup to GET all of a users entries based on their user ID which is all working, however it doesn't decrypt the entries. (screenshot below)

[Screenshot 2021-11-13 at 15.27.07.png]

I have watched some guides on decrypting and it was touched on in office hours this week, however I can't get it working in tandem with the GET api for the entries. 

Any help would be massively appreciated!

Comments

  • Toby -2289678
    Options
    I think a for each loop would work with a decrypt for each item
  •  Thanks Toby. I'm a bit of a noob building these stacks still, do you know what the specifics for that might look like?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     you would need a for each loop (entries as entry) and then an update variable command. the update variable command would set entry to itself but that would allow you to use several set filters which would then allow you to decode the data on the flow.

    visually it would look like this.

    foreach: entries as entry
      update: var:entry = var:entry
          |set("Input1", var:entry.Input1|jwe_decode(...))
          |set("Input2", var:entry.Input2|jwe_decode(...))
          |set("Input3", var:entry.Input3|jwe_decode(...))

    If you come to office hours we could show you this in action fairly quickly..
  •  Thanks Sean! It's starting to make a little more sense but booked into Tuesday's office hours. Thanks!