This is dynamic page , and there is a repeater to display the content of dataset .
I mad a filter to the dynamic set so each user can see their own items.
Ok now lets chose any item and click on view more .
And there we go , every thing running smoothly .
The idea is :
If mike have an account and took the url of this item in the picture (this item _owner is mike)
And send it to another user called carl , carl will be able to see the content of this item .
This is the problem I have I want to make a security wall to check if the user is the owner of this item or not , if he is the owner show content and if it is not re direct the user to the homepage.
but I want to do it in a professional way with router or hooks
can you help me because I tried to read about it but I did not understand any thing and nothing work for me
this is my failed try with router :
import { forbidden, next, ok } from 'wix-router';
export function patient_afterRouter(request, response) {
if (response.data._owner === request.user._id) {
return next();
}
return forbidden();
//TODO: write your code here...
}
i am struggling with this for many days and read all docs about router and hooks , any help ?
The request.user.id should be without an underscore (.id not ._id).
But why wouldn't you run it as part of the query ? :
//routers.js export function patient_customizeQuery(request, route, query) { return query.eq('_owner', request.user.id); }