-
Notifications
You must be signed in to change notification settings - Fork 71
Develop #171
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
Open
juansm1701
wants to merge
5
commits into
VolunChain:main
Choose a base branch
from
juansm1701:Develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Develop #171
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f73b049
fix: resolve TypeScript compilation errors
Villarley cf506fe
refactor: simplify route structure and remove versioning
Villarley 3ffbf99
feat: implement robust wallet-based authentication architecture
Villarley c08ac66
feat: update database schema for wallet-based authentication
Villarley 66e25ad
feat: overhaul authentication system with wallet-based login, user reβ¦
Villarley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| # Wallet-Based Authentication Flow | ||
|
|
||
| ## Overview | ||
|
|
||
| VolunChain now uses wallet-based authentication instead of traditional email/password authentication. This provides a more secure and decentralized approach to user identification. | ||
|
|
||
| ## Registration Flow | ||
|
|
||
| ### Endpoint: `POST /auth/register` | ||
|
|
||
| **Request Body:** | ||
|
|
||
| ```json | ||
| { | ||
| "name": "John Doe", | ||
| "email": "[email protected]", | ||
| "walletAddress": "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", | ||
| "profileType": "user", // or "project" | ||
| "lastName": "Doe", // optional, for users | ||
| "category": "environmental" // required for projects | ||
| } | ||
| ``` | ||
|
|
||
| **Response:** | ||
|
|
||
| ```json | ||
| { | ||
| "success": true, | ||
| "message": "User registered successfully", | ||
| "userId": "uuid-here" | ||
| } | ||
| ``` | ||
|
|
||
| ### Profile Types | ||
|
|
||
| 1. **User Profile** (`profileType: "user"`) | ||
|
|
||
| - Requires: name, email, walletAddress | ||
| - Optional: lastName | ||
| - Auto-verified upon registration | ||
|
|
||
| 2. **Project/Organization Profile** (`profileType: "project"`) | ||
| - Requires: name, email, walletAddress, category | ||
| - Auto-verified upon registration | ||
|
|
||
| ## Login Flow | ||
|
|
||
| ### Endpoint: `POST /auth/login` | ||
|
|
||
| **Request Body:** | ||
|
|
||
| ```json | ||
| { | ||
| "walletAddress": "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
| } | ||
| ``` | ||
|
|
||
| **Response:** | ||
|
|
||
| ```json | ||
| { | ||
| "success": true, | ||
| "message": "Login successful", | ||
| "token": "jwt-token-here", | ||
| "user": { | ||
| "id": "uuid-here", | ||
| "name": "John Doe", | ||
| "email": "[email protected]", | ||
| "wallet": "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", | ||
| "profileType": "user" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Protected Routes | ||
|
|
||
| ### Authentication Middleware | ||
|
|
||
| All protected routes require a valid JWT token in the Authorization header: | ||
|
|
||
| ``` | ||
| Authorization: Bearer <jwt-token> | ||
| ``` | ||
|
|
||
| ### Profile-Specific Routes | ||
|
|
||
| - `/auth/user-only` - Only accessible by user profiles | ||
| - `/auth/organization-only` - Only accessible by organization profiles | ||
| - `/auth/profile` - Accessible by both profile types | ||
|
|
||
| ## Security Features | ||
|
|
||
| 1. **Wallet Address Validation**: Ensures wallet addresses are valid Stellar addresses (56 characters) | ||
| 2. **Unique Wallet Constraint**: Each wallet address can only be registered once | ||
| 3. **JWT Tokens**: Secure token-based authentication with 24-hour expiration | ||
| 4. **Auto-Verification**: All wallet-based registrations are automatically verified | ||
|
|
||
| ## Error Handling | ||
|
|
||
| ### Common Error Responses | ||
|
|
||
| **Wallet Address Not Found:** | ||
|
|
||
| ```json | ||
| { | ||
| "success": false, | ||
| "message": "Wallet address not found" | ||
| } | ||
| ``` | ||
|
|
||
| **Wallet Address Already Registered:** | ||
|
|
||
| ```json | ||
| { | ||
| "success": false, | ||
| "message": "Wallet address already registered" | ||
| } | ||
| ``` | ||
|
|
||
| **Invalid Token:** | ||
|
|
||
| ```json | ||
| { | ||
| "success": false, | ||
| "message": "Invalid or expired token" | ||
| } | ||
| ``` | ||
|
|
||
| ## Migration Notes | ||
|
|
||
| - Password fields have been removed from User and Organization models | ||
| - All existing authentication logic has been updated to use wallet-based auth | ||
| - Email verification is no longer required for wallet-based registrations | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminology drift: βprojectβ vs βorganizationβ. Pick one and use it consistently.
Docs mix βprojectβ (profileType value) with βorganizationβ (route names). The codebase uses Organization as the model and register.usecase returns βorganizationβ. Align terms across request/response, routes, and models.
Example (if choosing "organization"):
And update request/response samples accordingly.
Also applies to: 87-89, 36-40
π§° Tools
πͺ LanguageTool
[grammar] ~42-~42: There might be a mistake here.
Context: ...ion Profile** (
profileType: "project") - Requires: name, email, walletAddress, ca...(QB_NEW_EN)
[grammar] ~43-~43: There might be a mistake here.
Context: ...es: name, email, walletAddress, category - Auto-verified upon registration ## Logi...
(QB_NEW_EN)
π€ Prompt for AI Agents