New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use auth() method? #66
Comments
Hi @kvlknctk. You can use something like this in middlewares/auth.js:
And don't forget to use it at your router:
|
When I use auth (), I know that we cannot pass guests in any way. Even if we do this somehow, I guess there must be a method where I can get the credentials of the user inside the controller. |
@kvlknctk you can also make this endpoint public (avoid using the |
This way I created an intermediate layer for myself, I hope I did it right. |
@kvlknctk doesn't this fail when It also doesn't make sense to use it here, so you can remove that part. The rest looks fine and intuitive. |
Yes, you right. |
Hi,
I need to use auth () to activate users who log in with tokens.
In this case, we can take the user as req.user in the controller and perform the operation.
But in any case, I have to check the req.user information.
my scenario is as follows:
Without auth (), a route is broadcasting publicly.
The user can view this route without logging in.
I want to send an additional field if it is logged in and has a relationship with the content it looks at /ep/54e...
I want to do something like "You have purchased this product before, you don't need to buy it again". /ep/54e.../buy
I have to define auth () under any condition to get the req.user information. but I also want my route to be public.
How can I verify if the request is from a verified user?
How should I use the auth () alternative methods?
Thank you.
The text was updated successfully, but these errors were encountered: