-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Partial] Auth setup part 3/n #21
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes significant updates to the authentication system, database schema, and user interface components. The changes introduce new API routes for login, logout, and registration, update the database schema, and add a new unauthorized access page.
Authentication System Updates:
app/api/auth/login/route.ts
: Added a new POST route for user login, including validation, password verification, and session token generation.app/api/auth/logout/route.ts
: Added a new DELETE route for user logout, including session invalidation and cookie deletion.app/api/auth/register/route.ts
: Added a new POST route for user registration, including validation, password hashing, and session token generation.Database Schema Updates:
db/schema.ts
: Updated theusers
table to includeemail
with a unique constraint and removed theuserEmails
table. Fixed formatting issues in multiple table definitions. [1] [2] [3] [4] [5] [6] [7] [8]User Interface Components:
contexts/auth-context.tsx
: Created an authentication context with login, signup, and logout methods, and a provider component to manage authentication state.mint/unauthorized.tsx
: Added a new unauthorized access page with a logout button and a message for users without permission.app/unauth/page.tsx
: Created a new page that renders theUnauthorizedPage
component.Utility Functions:
lib/client/fetch.ts
: Added a utility functionfetchApi
to handle API calls with proper headers and error handling.lib/server/cookies.ts
: Added functions to set and delete session token cookies.Additional Changes:
lib/validations.ts
: Added validation schemas for login and registration data.package.json
: Added theoslo
package for password hashing.