feat(frontend): add login behavior
This PR adds the api cube to the CW instance and adds support for logging in. For now the url to the backend is hardcoded, but can later be set using env variables.
To handle forms, we use react-hook-forms
as it is the library I am the most familiar with and works perfectly for our use cases.
As the nextjs backend cannot know whether a user is logged in or not (does not have access to the token and cannot check its secret), we simply check if the user is on a route different than /login
to know if it is logged in or not. When the rest of the app is connected to the CW backend, then a 401 error would logout the user.
For now the logout action simply redirects the user to Support has been added the the api cube. The logout action properly invalidates the auth cookie./login
as the api cube lacks a /logout
route.