@Hummingbird wrote:
Given the situation where a user has some sort of token stored in a cookie or local storage, which enables the app to automatically log in and the user calls the page via a link or reloads the browser.
So, given the url http://localhost/books/1 the first problem to me is that I would need to authenticate the user before the model hook is called, as the user will not be able to retrieve the book with id 1 before he is authenticated. However, I am not aware that there is the possibility to authenticate the user in the beforeModel hook, as I would need to wait for the promise of the login to be resolved before I am able to continue to the model hook.
I currently created an auto-login route, where I redirect to in the beforeModel hook, and after the user is authenticated I redirect back to the route the user actually wanted to see. This however feels like a bad workaround. Is there any way to authenticate a user during loading the app?
Posts: 1
Participants: 1