How can I get specific users posted data from Mongo dB? - reactjs

In react application I used a form to inserted data and with express JS I post this data to mongo db.
when people is logged in the can insert data using form. and there is a page where user can view and delete their inserted data. Problem is how can I load data that was inserted by specific user?

When any user log in and user insert data also store user_id with
every entry. Now get data from DB by using current user logged in
user_id and display that specific data on front end. That's it.
Comment below for any query.
Thanks

Related

Best way to implement one-time feature after signup?

Note: This is likely a duplicate question but I couldn't search for a solution/suggestion for my use case, so if anyone can re-direct me, that would be appreciated.
Problem: I have a NextJS application that runs on Prisma ORM and MySQL database. I am using NextAuth for OAuth authentication for sign up and log in.
So far the application works just fine but I want to check whether a user is logging in for the first time and redirect them to a set up page whether they would input personal details in order to populate a table on the database, so that the app can form a dynamic page based on their newly added information.
On the database, there are the user table (populated by NextAuth immediately at login) and the profile table.
Under NextAuth, the user table is populated automatically with the account's user name and email etc. However, that is not a unique entry and NextJS getStaticPath requires a unique entry to generate a dynamic page. That's why I have created the profile table to allow users to add their custom username where the dynamic URL will be generated (e.g. localhost:3000/u/[slug])
Here's my question - I want to check that the user is first time logging in and send a form for them to fill out the necessary information to input data onto the profile table, otherwise they would go straight to their profile homepage. What is the best way to check that and to redirect them to that form page?
Do I do it at server side with getServerSideProps by checking that the id from user table is missing from the profile table and do a redirect? Or is there some method that's customarily used to implement this "initial set-up" procedure?

Is this possible to create a private report filtering in Data Studio embeded report

I created a report in DataStudio and embedded it on my website. I activated the option "anyone with the link can view" so this report will be visible to my website users.
But I need to show my website users different data depending on their user ids and more important I don't want users would be able to see other users' data so if I used URL filtering users would be able to breach and search another user id to see his data.
Does anyone have a solution for this scenario?
In Google documentation I saw an option to limit the report to users in my domain, I assume this will solve this issue, but I don't find how to restrict other domains.
Users are logged onto Google
If users of your website are already logged onto Google, use the Filter by email address guide from Data Studio help center. This requires you to setup FILTER BY EMAIL and then have a field in your data can be directly used as an email filter.
Users are not logged on to Google
If you want a solution where the users don't have to be logged onto Google, you will need to:
Create a Community Connector to pass the filtered data to your users. The connector should accept a short lived token as part of the config.
Create a dashboard with your connector and pass unique short-lived tokens for each user.
You should have an endpoint that returns the current user's data based on the token provided. Alternatively, the endpoint can return only the user's identify and you can query a secondary data source with a service account filtering for the user's identity.
Your connector should call your endpoint to fetch data only for the user/for the user's identity.
This official guide demonstrates how to implement this in more details.
Disclaimer: I work in the Data Studio team and wrote the above guide.
First option is to add extra 2 fields to your data source.
User_ID
Password
For example:
Data, User_ID, Password
$10,Daniel,123
$20,Alex,456
In your dashboard, you need to create two parameters:
User_ID_Parameter
Password_Parameter
Both parameters can set the default value to null, and accepts any values.
Then create a new calculated field:
CASE
WHEN REGEXP_MATCH(User_ID,USER_ID_Parameter) AND REGEXP_MATCH(Password,Password_Parameter) THEN 1
ELSE 0
END
Then create a new filter to the chart that you want to hide:
To include the above calculated field Equal to 1
Second option is to use the Data Studio default Row Level Security
The only caveat is the users need to sign in before they can view the report.

Keeping a data table in session for current user

I have a C# .net 4.5 website where users select certain data fields and then they get generated and the user can download the data.
There is a new feature management wants me to add that will allow users to select any field even if there are fields that do not go together and when the user submits this job I have to split out the fields and generate however many jobs it takes to create them.
Without having to change my entire back end process I wanted to store the users selections in a data table in memory and when they submit I can loop through the table and submit the jobs accordingly.
What would be the best way to have a data table that will be alive during the entire user session? Should I create it as a session variable? The user can come back and add or remove from it at anytime while on the site.
Thank you

Check if database table has been updated

I have a model class 'Shop' with a related database table. The table is large and we are changing the way the clients load the data.
Up until now, mobile clients would just retrieve the whole table and reload the list in app, but now developers started to work with local memory, so they would not have to reload all records every time.
So from them I expect to get a timestamp of when a user has last logged in and check if any records have been added/updated after that and return the new/updated data, but I just do not know where to start from.

cakePhp-Session and DB-table modification

I can access a logged in user with $this->Auth->user(); in the controllers. That’s so far clear.
If I add some new DB field in the users table, clear the cake cache and logs in again then still I can not find the new field in the returned user record with $this->Auth->user(). This field is also missing in the session file on the server. What is it which I am missing?

Resources