Making files private to non-logged users

Hi, I need help with something I’ve been struggling for the last couple hours. I’ll give some brief context first.

I set up a File Uploader in my app that adds files to a Custom State thats a list of files and displays it in a repeating group:

Then, taking the values from the different inputs and the list of files, I create two Things via a workflow:

This adds two records: one in a table called Information_Id_Document (which has data such as the Id Number, type of document, etc.) and the other one in a table called Id_Document (which contains a list of files, which are the files I uploaded, and a field Id_Information_Document that connects this record to the other table’s one).

Then, I show the info from Information_Id_Document in a table, which has the option of viewing the related files of said record:

Related files are shown here and if I click them I trigger a Javascript workflow with the Toolbox plugin that opens the file’s url in a new tab:

Whole idea of the process is that ONLY logged in users can see the files, so if a non-logged user opens the url the file should not be shown. However, that is, of course, not happening still.

I know I may have to attach the files to the Id_Document record and establish some Privacy Rules or something, but I don’t really know how to attach the multiple files I have on my Custom State list to a record that hasn’t even been created yet.

Any ideas on how I could solve this issue? Maybe there’s other approaches?

Many thanks.