mycookbook / web-client

cookbookshq frontend
https://web.cookbookshq.com
Other
1 stars 1 forks source link

feat: implemented smart redirect #168

Closed captainPrime closed 1 year ago

captainPrime commented 1 year ago

Description

This pull request implements a feature that redirects the user back to the page they were on after they sign in. The feature uses Vue.js, Vuex, and vue-router to store the redirect path before the login action and then redirects the user to the stored path after successful login.

How Has This Been Tested?

I have tested this feature using the following steps:

  1. Set up a Vue.js project with Vue Router and Vuex.
  2. used the signin component that stores the current route path before login and redirects the user back to the stored path after successful login.
  3. Manually tested the sigin and redirection functionality by navigating to different routes and logging in.
  4. Created an end-to-end (E2E) test using Nightwatch.js to verify the login and redirection functionality automatically.
  5. Ensured that the E2E test passes successfully by running npx nightwatch.

Checklist:

fokosun commented 1 year ago

I didn't see the logic that remembers where the user was and redirects them back after login. Did I miss it? Also, I didnt see the logic that handles redirecting the user to the page they were if they happen to logout due to expired session and log back in. Depending on where they were, the request should also contain unsubmitted form data if they were on a page that has a form. So fir example they were creating a recipe, then they were primpted to log out and log in again, the request should remember both the route they were and the form payload so that the frontend can use the data to repopulate the form again so they dont have to start from scratch again.

https://stackoverflow.com/questions/53788975/vue-router-how-to-get-previous-page-url https://prismic.io/docs/vue-route-parameters

I was expecting a middleware or some implementation not tightly coupled to any component, to make it reuseable everywhere and just work automatically right out of the box.

fokosun commented 1 year ago

Converted back to draft since it is still a WIP

captainPrime commented 1 year ago

I

captainPrime commented 1 year ago

I didn't see the logic that remembers where the user was and redirects them back after login. Did I miss it? Also, I didnt see the logic that handles redirecting the user to the page they were if they happen to logout due to expired session and log back in. Depending on where they were, the request should also contain unsubmitted form data if they were on a page that has a form. So fir example they were creating a recipe, then they were primpted to log out and log in again, the request should remember both the route they were and the form payload so that the frontend can use the data to repopulate the form again so they dont have to start from scratch again.

https://stackoverflow.com/questions/53788975/vue-router-how-to-get-previous-page-url https://prismic.io/docs/vue-route-parameters

I was expecting a middleware or some implementation not tightly coupled to any component, to make it reuseable everywhere and just work automatically right out of the box.

I refactored the approach to this feature... updated the auth middleware to handle saving the previous page and redirecting after login