gramps-project / gramps-web

Frontend for Gramps Web
https://www.grampsweb.org
GNU Affero General Public License v3.0
381 stars 50 forks source link

Password reset link sometimes only working after emptying cache #14

Closed DavidMStraub closed 3 years ago

windmark commented 3 years ago

Hi @DavidMStraub I have a question related to the password reset link and thought it could fit to this issue. It could also fit the gramps-webapi repo, not sure.

My gramps-webapi has been set up and successfully emails the password reset link. However, when clicking the link I'm met by an empty front page with only the menu. I'm logged in, sure, but there is nowhere to actually change the password. What is the expected view at this point? The response is a 200 with the content below.

Response content gramps-js

Furthermore, I'm getting 401 from the /metadata and /translations at this stage.

DavidMStraub commented 3 years ago

Something showing in your console (F12)?

windmark commented 3 years ago

Something showing in your console (F12)?

See the screenshots below. I'm getting a 200 with the response in my post above. This time around I'm met with a not logged in error and it doesn't seem like the access tokens are correctly set.

What behavior are you experiencing?

Chrome Network Console

Console Output

DavidMStraub commented 3 years ago

I'm confused; do you see the login form or are you logged in and only see the menu?

It's not clear to me whether you are having a problem with the frontend or the backend. Can you please try whether fetching a token etc. works when just using curl with the backend?

By the way, the password reset link is not supposed to show Gramps.js at all. It is supposed to show an HTML form that is directly provided by the backend. Can you try pasting the reset link into a private browser tab?

windmark commented 3 years ago

Ah I see, I thought it was Gramps.js displaying it based on the jwt token. When I first created this issue I was logged in but only saw the menu. Unrelated to this I updated the Gramps.js and gramps-webapi versions and was then met with the login page.

It does indeed work when running in incognito mode (or simply deleting the Site Data in Chrome). It seems like if I deregister and stop the Service Worker it works. As soon as I have one running I'm met with the Login page and not the Update Password page.

It turns out to actually be related to "Password reset link sometimes only working after emptying cache" as per the title of the issue.

Thanks for all the help!

DavidMStraub commented 3 years ago

Thanks for investigating and confirming that bug! Now if only I knew how to fix it... unfortunately I am quite ignorant about how the service worker actually works...

DavidMStraub commented 3 years ago

I believe this is now fixed in main (the trick was to exclude /api/ from workbox's NavigateFallback), but it would be great if somebody could confirm that.

windmark commented 3 years ago

I believe this is now fixed in main (the trick was to exclude /api/ from workbox's NavigateFallback), but it would be great if somebody could confirm that.

Hi @DavidMStraub I finally had some time over to check this on my deployment and https://github.com/DavidMStraub/Gramps.js/commit/33362d4e86fef09b771a36abff3ef20d66220034 indeed seems to have solved the issue. Thank you!

DavidMStraub commented 3 years ago

Great, thanks for checking!