systemphil / symposia

Symposia is a philosophy course platform🏺
https://symposia.sphil.xyz
Apache License 2.0
6 stars 1 forks source link

Add auth flow with parallel routes #17

Closed Firgrep closed 5 months ago

Firgrep commented 12 months ago

When it comes to handling and routing authentication, it may be good to build out the base system. I came across this guy who uses parallel- and intercept routing in nextjs to deal with auth flow, and it looks quite nice. See below. What do people think?

You can check out the code here - notice the two @auth and (auth) folders: https://github.com/joschan21/breadit/tree/master/src/app/(auth)

He made a YT video about that code. I think only intro and the auth stuff are relevant for us right now: https://youtu.be/mSUKMfmLAt0?si=orDCBmcwJt3LGDNI&t=1800

NextJS docs on intercepting routes https://nextjs.org/docs/app/building-your-application/routing/intercepting-routes

ej-choi commented 11 months ago

This feature will be tackled incrementally.

We must implement an auth flow that works with course enrollment, and a variety of other entries points into the flow.

Auth pages

routes: /sign-in, /sign-up

The user will initially be directed to the route sign-in with a button below for passage into the route sign-up. [In the beginning there will be few users so it may make more sense to prioritise sign-up before the sign-in page]

Auth Flow

The simplest case of user authentication is when the user decides to sign-in/up from a top navigation bar, or a vanilla sign-in/up button without any need for redirection into a specific page.

However, it would be handy for the user to be sent back to the page the initiated the auth flow from in order to maintain a pleasant user experience.

<any page in symposia> ->
<sign-in page> ->
<user signs in> ->
<1st page in flow>

In the case of the user authenticating to initiated course enrollment, a redirection to the course enrollment page is necessary. The flow in that case would look something like this:

<course detail page> ->
<user clicks "sign-in/up to enroll"> ->
<sign-in page> ->
<user signs in> ->
<course enrollment page>

As such, we require a redirection mechanism that will be able to handle the course enrollment flow at the minimum, and optimally the most basic kind of redirection set in the first flow diagram above.

Firgrep commented 8 months ago

Having tried this pattern with parallell and intercept routes at work, I can see now that it doesn't really achieve what I first expected. It's actually better (and easier) to just generate a pop-up window for the login flow.

Firgrep commented 5 months ago

ref #49