Skip to content
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

Admin: schema , admin Role Type-in nextauth , loginPage , auth.ts modification #281

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

ShivanshPlays
Copy link
Contributor

@ShivanshPlays ShivanshPlays commented Nov 10, 2024

Add Admin Role and Admin Login Functionality

Description

This PR introduces the Admin Role for the application, adds functionality for Admin Login, and modifies the authentication logic to handle the admin role type. The following changes have been made:

Changes:

  1. Admin Schema in Prisma:

    • A new Admin model has been added to the Prisma schema.
    • The Admin model includes:
      • id: Unique identifier.
      • email: Admin email for login.
      • password: Admin's encrypted password.
      • role: Admin role, which could be used for different permissions.
  2. NextAuth Role Configuration:

    • Modified the NextAuth configuration to include an admin role type.
    • The role of the user is now part of the JWT token and is checked during session creation.
    • Admins are given special access based on their role.
  3. LoginPage:

    • Created the admin LoginPage to allow admin users to sign in using their credentials.
    • will be made functional in subsequent PRs
  4. auth.ts Modification:

    • Updated auth.ts to handle the admin role logic:
      • Ensures that users with the admin role can authenticate and be authorized to access admin routes.
      • Proper error handling has been added for failed login attempts.
      • The JWT and session callbacks have been updated to include the role of the user for authorization checks.

PR1 #268

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Thank you for contributing to this project, your support is much appreciated.

Stay awesome! 😎

@Vimall03 Vimall03 merged commit 66ed023 into Vimall03:main Nov 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants