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

feat:user-auth-api #18

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

zleypner
Copy link

@zleypner zleypner commented Dec 14, 2024

🚀 StarShop Pull Request

Closes #12

  • Run formatting
  • Evidence attached
  • Commented the code

📝 Changes Description

Implementing user authentication system with the following features:

  • Added authenticateUser service method in UserService.
  • Created new POST /auth/login endpoint for wallet-based authentication.
  • Implemented JWT token generation and validation middleware.
  • Added Swagger/OpenAPI documentation for the authentication flow.

Implementation Highlights:

  • Uses JWT for secure token generation with 1-hour expiration.
  • Validates wallet addresses before authentication.
  • Includes user role in JWT payload for authorization.
  • Environment-configurable JWT secret key.

📸 Evidence

Pending

⏰ Time Spent Breakdown

The time spent on this task involved various stages of development, with some additional delays caused by resolving persistent errors, will be specified one the issue has been completed.

Overall, the task required more time than anticipated, as errors needed to be addressed systematically to ensure a robust and secure implementation.

  • Documentation: Focused on detailed documentation to ensure clarity for future contributors, which required significant revisions.

🌌 Comments

Before reviewing this PR, please note:

  • This implementation follows the Contributors Guide.
  • JWT secret should be properly configured in production.
  • Token expiration is set to 1 hour but can be adjusted based on requirements.
  • Error handling follows project conventions with appropriate status codes.

Acceptance Criteria to be Met:

  • ✅ POST /auth/login endpoint implemented
  • ✅ JWT token generation working
  • ✅ Middleware validates tokens
  • ✅ User details attached to request object

@zleypner
Copy link
Author

🚧 Work in Progress: I am working on this issue and will update with implementation progress ASAP ⚡

@zleypner
Copy link
Author

Hello @Villarley , I did an updated. I will wait for a feedback. I still need to continue and improve the method.

@Villarley
Copy link
Contributor

Hello @Villarley , I did an updated. I will wait for a feedback. I still need to continue and improve the method.

Hey Anwar, everything looks good when you finish please resolve conflicts. Great work🫡

@zleypner
Copy link
Author

Hello @Villarley, thank you for the feedback!
I am workin on finishing the improvements and will make sure to resolve any conflicts before wrapping up.

@zleypner
Copy link
Author

Currently getting the following error. Once fixed, I will proceed to test end point properly with Postman.

Error during Data Source initialization: AggregateError:
at internalConnectMultiple (node:net:1116:18)
at afterConnectMultiple (node:net:1683:7) {
code: 'ECONNREFUSED',
[errors]: [
Error: connect ECONNREFUSED ::1:5432
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 5432
},
Error: connect ECONNREFUSED 127.0.0.1:5432
at createConnectionError (node:net:1646:14)
at afterConnectMultiple (node:net:1676:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
]
}

@zleypner
Copy link
Author

zleypner commented Dec 21, 2024

Hello @Villarley! 👋
🚧 Working to move forward.

New error while trying to run the backend:
[INFO] 02:22:25 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 5.7.2)
Error during Data Source initialization: Error: The server does not support SSL connections
at Socket.
at Object.onceWrapper (node:events:633:26)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Socket.Readable.push (node:internal/streams/readable:390:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

FYI, I had to update the ormconfig as the PostgreSQL configuration was trying to use SSL, as the local DB mentioned does not support it.

✅ Fixed.

🚀 We are moving forward!

@zleypner
Copy link
Author

Hello there! Currently testing with postman. I will upload updates soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BK]: Add User Authentication (API)
2 participants