BearStudio / start-ui-web

πŸš€ Start UI [web] is an opinionated UI starter with 🟦 TypeScript, βš›οΈ React, ⚫️ NextJS, ⚑️ Chakra UI, 🟦 tRPC, β–² Prisma, πŸ–οΈ TanStack Query, πŸ“• Storybook, 🎭 Playwright,πŸ“‹ React Hook Form,β—½From the 🐻 BearStudio Team
https://demo.start-ui.com
MIT License
1.36k stars 128 forks source link

Fix(logout) : Logout not working when deployed #482

Closed ntatoud closed 3 months ago

ntatoud commented 3 months ago

Describe your changes

closes #481 Make the logout mutation async so that it can be awaited properly

Question : Is there still a point to making the optimistic update ?

The code before : (await has no effect) image

This lead to : Redirection happening before the logout and triggering checkAuthenticated before the end of logout. Reminder : checkAuthenticated sets a new auth cookie.

What happend before on the logout page :

  1. Call logout
  2. Redirection
  3. Call checkAuthenticated (user still in context)
  4. Suppression of the cookie
  5. Cookie set again in checkAuthenticated
  6. User not logged out

image

After the fix: image

Checklist

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
start-ui βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 30, 2024 4:10pm
sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud