-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT: single session/login #119
Conversation
👷 Deploy request for charming-semolina-f274cf pending review.Visit the deploys page to approve it
|
@siinghd is attempting to deploy a commit to the My Team Team on Vercel. A member of the Team first needs to authorize it. |
wait before merging , let me add also the admin part and test it properly |
ok, should be working fine, tested at https://incomparable-biscotti-b0e8a5.netlify.app @hkirat NEXT_PUBLIC_BASE_URL_LOCAL(should be https://app.100xdevs.com , i think), JWT_SECRET needs to be set, NEXTAUTH_URL needs to be set too correct url (https://app.100xdevs.com) i think. 2024-02-26.12-10-11.1.mp4 |
@siinghd displaying a toast to the end user would be a nice UX. Could you please accept those changes |
return NextResponse.redirect(new URL('/invalidsession', req.url)); | ||
} | ||
const user = await fetch( | ||
`${process.env.NEXT_PUBLIC_BASE_URL_LOCAL}/api/user?token=${token.jwtToken}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing something or do middlewares run on the client?
Any reason for this to be a fetch and not a db call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to use prisma in middleware we need to use accelerate and prisma edge, prisma/prisma#21310, middleware runs on edge runtime
/bounty $150 |
This pr should add support #101
Key changes need to be added:
ENV: set
JWT_SECRET
, correctly as its being usedDB: user model has new field called
token
NEXT_PUBLIC_BASE_URL_LOCAL="http://localhost:3000"
-> set this to the correct oneMiddleware: check for the token mismatch to redirect the user to signout.
Currently with nextauth you cannot logout the user on server side so im just redirecting the user to a page and doing singout in the useeffect.
Also middleware runtime is edge so it doesnt support db querying directly from there unless you don't use prisma accelerate and prisma edge client.
Missing: admin can logout the user