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:
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.
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.
LoginPage:
Created the admin LoginPage to allow admin users to sign in using their credentials.
will be made functional in subsequent PRs
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.
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:
Admin Schema in Prisma:
id
: Unique identifier.email
: Admin email for login.password
: Admin's encrypted password.role
: Admin role, which could be used for different permissions.NextAuth Role Configuration:
admin
role type.role
of the user is now part of the JWT token and is checked during session creation.role
.LoginPage:
LoginPage
to allow admin users to sign in using their credentials.auth.ts Modification:
auth.ts
to handle theadmin
role logic:admin
role can authenticate and be authorized to access admin routes.role
of the user for authorization checks.PR1 #518