Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Going to the webpage should redirect to `/dashboard` for signin users

Open fozziethebeat opened this issue 3 years ago • 7 comments

Right now if a user goes to the main website, it goes to the signed out page which doesn't have any obvious call to actions for contributing. They can click the "dashboard" link in the user dropdown but it's not totally obvious.

Fixes might be:

  • Have an obvious call to action for signed in users
  • Redirect to /dashboard for signed in users

fozziethebeat avatar Jan 04 '23 10:01 fozziethebeat

I'm working on it!

Jakolo121 avatar Jan 04 '23 13:01 Jakolo121

My take would be this...

User is not authenticated: image

User is authenticated: image

Jakolo121 avatar Jan 05 '23 10:01 Jakolo121

Is there someway we can redirect the user to /dashboard when they're authenticated? I feel like that'd be the smoothest flow and reduce the number if button clicks needed.

fozziethebeat avatar Jan 05 '23 10:01 fozziethebeat

Should be a pretty easy thing to do. We have NextAuth.js useSession() hook to determine if user is authenticated. Then we could use NextJS useRouter() hook and push the /dashboard route.

Klotske avatar Jan 05 '23 13:01 Klotske

That sounds most ideal!

fozziethebeat avatar Jan 05 '23 23:01 fozziethebeat

Actually in the Signin function, there is a Redirect callback callbackUrl defined as /dashboard. By default only URLs on the same URL as the site are allowed, so either I added http://localhost:3000/dashboard or I add the redirect callback to [...nextauth].ts so that the baseUrl is appended to the callbackUrl.

Jakolo121 avatar Jan 06 '23 10:01 Jakolo121

The signin flow is working correctly. The part we need to fix is when an already signed in user goes directly to the website. When that happens they won't go through the signin and redirect flow, instead they'd land at /.

So @Klotske's solution would be the most appropriate. When a signed in user lands at / we should automatically redirect them to /dashboard.

fozziethebeat avatar Jan 06 '23 11:01 fozziethebeat