vibbin
Explore posts from serversTTCTheo's Typesafe Cult
•Created by vibbin on 5/12/2023 in #questions
Updating existing T3 with Supabase Auth from Next Auth
Background:
- Launched a T3 app with Next Auth.
- Currently got 3000 users.
- Launching an app version (expo), so migrating T3 app to T3-turbo.
- Upgrading Next-Auth to Supabase Auth to work with React Native, want to keep existing users and ease migration.
- Supabase generates an auth.users table.
I'm looking to guidance that I'm on the right track with my implementation.
1. I've added a new field to my existing Users table called SupabaseId. This will be the reference for Supabase Auth and my Users table. (Usually both id's would be the same.).
2. Created a webhook from Supabase when a new user is created in Supabase Auth (Signs up,in). The webhook hits an API to create a new user in the Users table of my DB and added the Supabase ID.
3. The new TRPC context. This bit feels abit hairy. I'm having to extend the supabase user and lookup the user from my DB on each request to add in the users ID and role.
Overall wondering if this approach is the correct one? My db id's are all cuid's and kind of wish I just started the uuid's and they seem much more used in industry.
Thanks
4 replies
TTCTheo's Typesafe Cult
•Created by vibbin on 1/23/2023 in #questions
Best provider for single sign on with Microsoft & Next Auth?
I'm having delivery issues using magic links and getting through to Microsoft Outlook / Business users with Next Auth. Lots of bounces and extra security causes the tokens to expire.
I'm a long time Mac user and terrible knowledge of Microsoft and their million different services.
If I want to help users sign up through single click via Microsoft whats the best provider to choose?
Azure AD B2C or Azure AD???
2 replies
TTCTheo's Typesafe Cult
•Created by vibbin on 1/17/2023 in #questions
Modifying Next Auth in T3 App
I've recently launched a T3 app and some users are having trouble authenticating through the Email provider/Magic Link when using a corporate email address and Microsoft Outlook.
I've searched online and the docs and come across this fix:
https://authjs.dev/guides/corporate-proxies/avoid-corporate-link-checking-email-provider
I'm struggling with how to implement this into the T3 app. Any ideas?
import type { NextApiRequest, NextApiResponse } from "next"
import NextAuth from "next-auth"
export default async function auth(req: NextApiRequest, res: NextApiResponse) {
if(req.method === "HEAD") {
return res.status(200)
}
...
}
1 replies
TTCTheo's Typesafe Cult
•Created by vibbin on 11/9/2022 in #questions
Serializing date with superjson
Think I'm going wrong somewhere implementing a server side request for the user and serlializing the data with superjson. Any ideas?
export const getServerSideProps = async ({ req, res }: GetServerSidePropsContext) => {
const session = await getServerSession(req, res, authOptions)
const ssg = createProxySSGHelpers({
router: appRouter,
ctx: await createContextInner({ session: null }),
transformer: superjson,
})
if (session?.user && !session.user.onboarded) {
const user = await ssg.user.getById.fetch({ userId: session.user.id })
const teams = await prisma.team.findMany({
select: {
id: true,
name: true,
image: true,
},
})
return {
props: {
trpcState: ssg.dehydrate(),
user: user,
teams: teams,
},
}
}
}
8 replies
TTCTheo's Typesafe Cult
•Created by vibbin on 9/27/2022 in #questions
Running a cron job alongside T3 stack locally
I want to have a cron job fetch some RSS feeds externally every 2 minutes and post to the db.
I can use an external service when deployed but what’s the best way to implement when developing locally?
I started creating a simple express app to run alongside but wondering if there’s any better alternatives?
4 replies