-
Notifications
You must be signed in to change notification settings - Fork 28
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
Smart Ations fields hooks endpoint cannot authenticate #1058
Comments
Hello, |
I don't have route declarations, this is all I have regarding the config app.use(await forest.init({ |
Do you follow this documentation to declare your smart action ? |
I'm using it with nestjs so not really. Just the part defining collection actions, not the part with router |
You must use the forestadmin middleware on the routes to be authenticated. |
Expected behavior
When I Create an action
I expect endpoint POST 'http://localhost:3000/api/forest/page-contents/playlists/videos/hooks/load' to be called and authentication completed and my endpoint to be called that returns a list of fields
Actual behavior
Current behavior is that it calls my endpoint 'http://localhost:3000/api/forest/page-contents/playlists/videos/hooks/load' but authentication fails with message Unauthorized: Forest cannot authenticate the user for this request. For some reason it doesn't have request.user and authentication fails even though all headers are sent as expected.
Smart action that is passing:
![image](https://private-user-images.githubusercontent.com/32249855/277426367-6201fa88-d63a-4544-b64e-b881fb8f59e9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwMzY1NzUsIm5iZiI6MTcyNTAzNjI3NSwicGF0aCI6Ii8zMjI0OTg1NS8yNzc0MjYzNjctNjIwMWZhODgtZDYzYS00NTQ0LWI2NGUtYjg4MWZiOGY1OWU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMwVDE2NDQzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwMTQwNzM1NDg4MmNiZjliN2QxM2UyMDhlM2ZjMmNmOWQyOTA0YWJlMTg3OTNhYjgxODM1ZjY4YjcxMzAxOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RxQj2gp08lJPJgwq58OFVYCbhUh4HFiCeP5XEdTGyzA)
And hook that is not passing:
![image](https://private-user-images.githubusercontent.com/32249855/277426472-3375db1a-ebfe-4c33-83b9-5b8609e59bac.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwMzY1NzUsIm5iZiI6MTcyNTAzNjI3NSwicGF0aCI6Ii8zMjI0OTg1NS8yNzc0MjY0NzItMzM3NWRiMWEtZWJmZS00YzMzLTgzYjktNWI4NjA5ZTU5YmFjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMwVDE2NDQzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIyODljOTEwOTBiMGM2YThlMTgzZjdiZjNmMjFlNTM5N2JhMGQ0ZDFjZGE1Mjk3NGVjMjE4MjdmZjhjYmYxZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FrB6AR7M5_Mm9L__ekpiuHV1TB7R6jvSJ8lCnTuc6ok)
Failure Logs
[Nest] 11268 - 23. 10. 2023. 19:45:42 ERROR [ExceptionsHandler] Forest cannot authenticate the user for this request.
Unauthorized: Forest cannot authenticate the user for this request.
at ensureAuthenticated (\node_modules\forest-express\dist\services\auth.js:16:17)
at dispatch (\node_modules\compose-middleware\src\index.ts:70:21)
at middleware (\node_modules\compose-middleware\src\index.ts:85:12)
at \node_modules\compose-middleware\src\index.ts:19:45
at Layer.handle [as handle_request] (\node_modules\express\lib\router\layer.js:95:5)
at next (\node_modules\express\lib\router\route.js:144:13)
at Route.dispatch (\node_modules\express\lib\router\route.js:114:3)
at Layer.handle [as handle_request] (\node_modules\express\lib\router\layer.js:95:5)
at \node_modules\express\lib\router\index.js:284:15
at Function.process_params (\node_modules\express\lib\router\index.js:346:12)
at next (\node_modules\express\lib\router\index.js:280:10)
at requestUnflattener (\node_modules\forest-express-mongoose\dist\services\flattener.js:253:16)
at Layer.handle [as handle_request] (\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (\node_modules\express\lib\router\index.js:328:13)
at \node_modules\express\lib\router\index.js:286:9
at Function.process_params (\node_modules\express\lib\router\index.js:346:12)
at next (\node_modules\express\lib\router\index.js:280:10)
at expressInit (\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (\node_modules\express\lib\router\index.js:328:13)
at \node_modules\express\lib\router\index.js:286:9
at Function.process_params (\node_modules\express\lib\router\index.js:346:12)
Context
The text was updated successfully, but these errors were encountered: