ajstars1 / auth_system

An Advanced Authentication System with Auth.js for your Personal NextJs project with Credentials and OAuth Providers in your Database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auth_System

Auth_System Icon

This is a repository for an Advanced Authentication System with Auth.js for your Personal NextJs project with Credentials and OAuth Providers in your Database.

Feature

  • ๐Ÿ” Next-auth v5 (Auth.js)
  • ๐Ÿš€ Next.js 14 with server actions
  • ๐Ÿ”‘ Credentials Provider
  • ๐ŸŒ OAuth Provider (Social login with Google & GitHub)
  • ๐Ÿ”’ Forgot password functionality
  • โœ‰๏ธ Email verification
  • ๐Ÿ“ฑ Two Factor verification
  • ๐Ÿ‘ฅ User roles (Admin & User)
  • ๐Ÿ”“ Login component (Opens in redirect or modal)
  • ๐Ÿ“ Register component
  • ๐Ÿค” Forgot password component
  • โœ… Verification component
  • โš ๏ธ Error component
  • ๐Ÿ”˜ Login button
  • ๐Ÿšช Logout button
  • ๐Ÿšง Role Gate
  • ๐Ÿ” Exploring next.js middleware
  • ๐Ÿ“ˆ Extending & Exploring next-auth session
  • ๐Ÿ”„ Exploring next-auth callbacks
  • ๐Ÿ‘ค useCurrentUser hook
  • ๐Ÿ›‚ useRole hook
  • ๐Ÿง‘ currentUser utility
  • ๐Ÿ‘ฎ currentRole utility
  • ๐Ÿ–ฅ๏ธ Example with server component
  • ๐Ÿ’ป Example with client component
  • ๐Ÿ‘‘ Render content for admins using RoleGate component
  • ๐Ÿ›ก๏ธ Protect API Routes for admins only
  • ๐Ÿ” Protect Server Actions for admins only
  • ๐Ÿ“ง Change email with new verification in Settings page
  • ๐Ÿ”‘ Change password with old password confirmation in Settings page
  • ๐Ÿ”” Enable/disable two-factor auth in Settings page
  • ๐Ÿ”„ Change user role in Settings page (for development purposes only)

Prerequisites

Node version 18.7.x

Cloning the repository

git clone https://github.com/ajstars1/auth_system.git

Install packages

npm i

Setup .env file

DATABASE_URL=
DIRECT_URL=

AUTH_SECRET=

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

RESEND_API_KEY=

NEXT_PUBLIC_APP_URL=

Setup Prisma

npx prisma generate
npx prisma db push

Start the app

npm run dev

Available commands

Running commands with npm npm run [command]

command description
dev Starts a development instance of the app

License

This project is licensed under the MIT License.

About

An Advanced Authentication System with Auth.js for your Personal NextJs project with Credentials and OAuth Providers in your Database.

License:MIT License


Languages

Language:TypeScript 98.2%Language:CSS 1.6%Language:JavaScript 0.2%