Blocks/Auth System
IntermediateCore

Auth System

Email + GitHub + Google OAuth with RBAC

The value is in the extras, not the setup: typed RBAC helpers (hasRole, requireRole, withAuth wrapper), full auth event audit log, password reset + email verification flows, and clean Supabase profile sync. The NextAuth config itself is a starting point — customise providers as needed.

14h
Time saved
487
Lines of code
100%
TypeScript
#auth#oauth#rbac#nextauth

Dependencies

next-authbcryptjs@supabase/supabase-jszod

Code preview

blocks/auth/index.ts
1export const authOptions: AuthOptions = {
2 providers: [
3 CredentialsProvider({ /* email + bcrypt */ }),
4 GitHubProvider({ clientId, clientSecret }),
5 GoogleProvider({ clientId, clientSecret }),
6 ],
7 callbacks: {
8 async jwt({ token, user }) {
9 if (user) {
10 const { data } = await supabaseAdmin
11 .from('profiles').select('id, role').eq('email', user.email!).single()
12 token.id = data?.id
13 token.role = data?.role ?? 'user'
14 }
15 return token
16 },
17 },
18 session: { strategy: 'jwt', maxAge: 30 * 24 * 60 * 60 },
19}

Short excerpt. Full block includes SQL migrations, error handling, RLS policies, and complete file structure.

$29

One-time · Instant GitHub access

🔜 Payments launching soon

We are setting up secure checkout. Email samarthofficial52@gmail.com to get early access.

You might also like