ygor perez
ygor perez
Explore posts from servers
TTCTheo's Typesafe Cult
Created by nyx5975 on 4/4/2023 in #questions
Clerk - multi-user login/profiles
Happy to help! Good luck with your project! 😁
21 replies
TTCTheo's Typesafe Cult
Created by Perfect on 4/4/2023 in #questions
Zod - instanceof z.ZodError
Good to know!
5 replies
TTCTheo's Typesafe Cult
Created by nyx5975 on 4/4/2023 in #questions
Clerk - multi-user login/profiles
Then in your middleware you could access that data and define if the user can access that page or not
21 replies
TTCTheo's Typesafe Cult
Created by nyx5975 on 4/4/2023 in #questions
Clerk - multi-user login/profiles
Maybe you could use the userMetadata shown in here: https://clerk.com/docs/users/user-metadata
21 replies
TTCTheo's Typesafe Cult
Created by Mads on 4/5/2023 in #questions
What is the convention for customizing sign-in pages in NextAuth
Happy to help!
12 replies
TTCTheo's Typesafe Cult
Created by Mads on 4/5/2023 in #questions
What is the convention for customizing sign-in pages in NextAuth
if you have any problems with the sign in reach out to me again!
12 replies
TTCTheo's Typesafe Cult
Created by Mads on 4/5/2023 in #questions
What is the convention for customizing sign-in pages in NextAuth
No problem Mads 😁 , I had some issues when I first tried to implement it myself too, the documentation isn't the clearest.
12 replies
TTCTheo's Typesafe Cult
Created by Mads on 4/5/2023 in #questions
What is the convention for customizing sign-in pages in NextAuth
I heard that this path to the sign in page is a convention
12 replies
TTCTheo's Typesafe Cult
Created by Mads on 4/5/2023 in #questions
What is the convention for customizing sign-in pages in NextAuth
src/pages/auth/signin.tsx
import { faSpotify } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { type Provider } from 'next-auth/providers'
import { getProviders, signIn } from 'next-auth/react'

interface SignInProps {
providers: Provider[]
}

const SignIn = ({ providers }: SignInProps) => {
return (
<>
<main className='flex min-h-screen w-full flex-col items-center justify-center bg-black'>
{Object.values(providers).map(provider => (
<div key={provider.name}>
<button
className='rounded-full bg-white p-4 text-xl transition-all delay-75 hover:scale-105 hover:bg-gray-200'
onClick={() => void signIn(provider.id, { callbackUrl: '/' })}
>
{provider.name === 'Spotify' && (
<FontAwesomeIcon
icon={faSpotify}
className='mr-4 rounded-full align-middle text-green-600'
size='2x'
/>
)}
Sign in with {provider.name}
</button>
</div>
))}
</main>
</>
)
}

export const getServerSideProps = async () => {
const providers = await getProviders()
if (!providers) {
throw Error('no providers found')
}
return {
props: { providers },
}
}

export default SignIn
import { faSpotify } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { type Provider } from 'next-auth/providers'
import { getProviders, signIn } from 'next-auth/react'

interface SignInProps {
providers: Provider[]
}

const SignIn = ({ providers }: SignInProps) => {
return (
<>
<main className='flex min-h-screen w-full flex-col items-center justify-center bg-black'>
{Object.values(providers).map(provider => (
<div key={provider.name}>
<button
className='rounded-full bg-white p-4 text-xl transition-all delay-75 hover:scale-105 hover:bg-gray-200'
onClick={() => void signIn(provider.id, { callbackUrl: '/' })}
>
{provider.name === 'Spotify' && (
<FontAwesomeIcon
icon={faSpotify}
className='mr-4 rounded-full align-middle text-green-600'
size='2x'
/>
)}
Sign in with {provider.name}
</button>
</div>
))}
</main>
</>
)
}

export const getServerSideProps = async () => {
const providers = await getProviders()
if (!providers) {
throw Error('no providers found')
}
return {
props: { providers },
}
}

export default SignIn
src/server/auth.ts
export const authOptions: NextAuthOptions = {
session: {
...
},
callbacks: {
...
},
},
adapter: PrismaAdapter(prisma),
providers: [
...
],
pages: {
// this is what matters
signIn: '/auth/signin',
},
}
export const authOptions: NextAuthOptions = {
session: {
...
},
callbacks: {
...
},
},
adapter: PrismaAdapter(prisma),
providers: [
...
],
pages: {
// this is what matters
signIn: '/auth/signin',
},
}
12 replies
TTCTheo's Typesafe Cult
Created by Perfect on 4/4/2023 in #questions
Zod - instanceof z.ZodError
Maybe try extracting the coursePost to it's own schema? This is from the docs:
try {
person.parse({
names: ["Dave", 12], // 12 is not a string
address: {
line1: "123 Maple Ave",
zipCode: 123, // zip code isn't 5 digits
extra: "other stuff", // unrecognized key
},
});
} catch (err) {
if (err instanceof z.ZodError) {
console.log(err.issues);
}
}
try {
person.parse({
names: ["Dave", 12], // 12 is not a string
address: {
line1: "123 Maple Ave",
zipCode: 123, // zip code isn't 5 digits
extra: "other stuff", // unrecognized key
},
});
} catch (err) {
if (err instanceof z.ZodError) {
console.log(err.issues);
}
}
Your code seems right, have you tried passing random things to be parsed?
5 replies
TTCTheo's Typesafe Cult
Created by peternovak on 1/29/2023 in #questions
How to make the NextAuth custom signin page typesafe?
I ended up disabling sSSR in the trpc config and now I'm using ssgHelpers
19 replies
TTCTheo's Typesafe Cult
Created by peternovak on 1/29/2023 in #questions
How to make the NextAuth custom signin page typesafe?
error - TypeError: Cannot convert undefined or null to object at Function.values (<anonymous>) at SignIn (webpack-internal:///./src/pages/auth/signin.tsx:24:30) at renderWithHooks (webpack-internal:///./node_modules/.pnpm/[email protected][email protected]/node_modules/react-ssr-prepass/dist/react-ssr-
19 replies
TTCTheo's Typesafe Cult
Created by peternovak on 1/29/2023 in #questions
How to make the NextAuth custom signin page typesafe?
the error came back help
19 replies
TTCTheo's Typesafe Cult
Created by peternovak on 1/29/2023 in #questions
How to make the NextAuth custom signin page typesafe?
nvm it seems that it magically solved itself after deleting cache and restarting the dev server
19 replies
TTCTheo's Typesafe Cult
Created by peternovak on 1/29/2023 in #questions
How to make the NextAuth custom signin page typesafe?
I'm new to this stack, sorry if there's something basic that I'm not getting, I would be really glad if someone could explain it to me why it's not working with SSR
19 replies