Store collection filter (from authorized users)

Hi there,
Could you help me with the following ↓

  1. I have an online store that contains several collections. I would like to show goods from collections only to a specific users who have been authorized on the site.

  2. I created a database collection “Clients” where I specified a condition

  1. I created a store page where I used two collections “datasetClients” and “datasetProducts”.

  2. I used the following code

import wixUsers from "wix-users";
import wixData from "wix-data";

$w.onReady(function () {
    wixUsers.currentUser.getEmail()
        .then( (email) => {
 let userEmail = email;
 let permissionEmail = $w("#datasetClients").getCurrentItem().password;
 // password field contains a valid email

 if (permissionEmail === userEmail) {       
 var collection = $w("#datasetClients").getCurrentItem().collection;
                $w("#datasetProducts").setFilter(wixData.filter()
                    .hasSome("collections.id", collection))
            } else {
                $w("#galleryProducts").collapse();
                $w("#columnStripMessage").expand(); // You are not authorized to view this category.
            }
    });

});

This code works … but the code works strangely. If I pass the authorization on the page with the goods, then after authorization on the site the gallery of goods displays all the goods of the store. Next, I refresh the page with the F5 (already authorized on the site) the product gallery displays the goods I need from the collection. If I logged in on the home page and then opened the store page, the filter works.

This is my first wixUsers experience. Any help would be helpful.