-
Notifications
You must be signed in to change notification settings - Fork 2
Api doc #26
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
Api doc #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,149 @@ | ||||||||||||||||||||||||||||
| # Endpoints for Authentication | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Register | ||||||||||||||||||||||||||||
| POST: `/api/Auth/register` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Request** | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "username": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "passwrod": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T22:27:00.026Z" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "success": true, | ||||||||||||||||||||||||||||
| "errors": [ | ||||||||||||||||||||||||||||
| "string" | ||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||
| "data": { | ||||||||||||||||||||||||||||
| "isAuthenticated": true, | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "refreshToken": { | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "expireOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isExpired": true, | ||||||||||||||||||||||||||||
| "revokedOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isActive": true, | ||||||||||||||||||||||||||||
| "createdOn": "2025-09-06T22:57:05.109Z" | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| "user": { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ----- | ||||||||||||||||||||||||||||
| ### Login | ||||||||||||||||||||||||||||
| POST: `/api/Auth/login` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Request** | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "password": "string" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "success": true, | ||||||||||||||||||||||||||||
| "errors": [ | ||||||||||||||||||||||||||||
| "string" | ||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||
| "data": { | ||||||||||||||||||||||||||||
| "isAuthenticated": true, | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "refreshToken": { | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "expireOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isExpired": true, | ||||||||||||||||||||||||||||
| "revokedOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isActive": true, | ||||||||||||||||||||||||||||
| "createdOn": "2025-09-06T22:57:05.109Z" | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| "user": { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ------ | ||||||||||||||||||||||||||||
| ### Refresh Token | ||||||||||||||||||||||||||||
| POST: `/api/Auth/refresh-token/{id}` | ||||||||||||||||||||||||||||
| Description: refersh token when jwt token is expired | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
Comment on lines
+96
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify refresh-token description and fix spelling. Align with controller behavior. If you accept making the action anonymous (suggested in code), reflect that here and note cookie requirement. -### Refresh Token
-POST: `/api/Auth/refresh-token/{id}`
-Description: refersh token when jwt token is expired
+### Refresh Token
+POST: `/api/Auth/refresh-token/{id}`
+Description: Refresh the access token using the HTTP-only `refreshToken` cookie.
+Auth: No Authorization header required (endpoint validates the refresh token).If you keep 📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~97-~97: There might be a mistake here. (QB_NEW_EN) [grammar] ~98-~98: There might be a mistake here. (QB_NEW_EN) [grammar] ~99-~99: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "success": true, | ||||||||||||||||||||||||||||
| "errors": [ | ||||||||||||||||||||||||||||
| "string" | ||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||
| "data": { | ||||||||||||||||||||||||||||
| "isAuthenticated": true, | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "refreshToken": { | ||||||||||||||||||||||||||||
| "token": "string", | ||||||||||||||||||||||||||||
| "expireOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isExpired": true, | ||||||||||||||||||||||||||||
| "revokedOn": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "isActive": true, | ||||||||||||||||||||||||||||
| "createdOn": "2025-09-06T22:57:05.109Z" | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| "user": { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T22:57:05.109Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Logout | ||||||||||||||||||||||||||||
| POST: `/api/Auth/logout/{id}` | ||||||||||||||||||||||||||||
| Description: refersh token when jwt token is expired | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+134
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix Logout description and spelling. -### Logout
-POST: `/api/Auth/logout/{id}`
-Description: refersh token when jwt token is expired
+### Logout
+POST: `/api/Auth/logout/{id}`
+Description: Revoke the refresh token and clear the cookie.📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~134-~134: There might be a mistake here. (QB_NEW_EN) [grammar] ~135-~135: There might be a mistake here. (QB_NEW_EN) [grammar] ~136-~136: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "success": true, | ||||||||||||||||||||||||||||
| "errors": [ | ||||||||||||||||||||||||||||
| "string" | ||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||
| "data": true | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||
| # Endpoints for User | ||||||||||||||||||||||||||||
| ### Get current user Profile | ||||||||||||||||||||||||||||
| GET: `/api/User/profile` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T23:04:42.634Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Get User By | ||||||||||||||||||||||||||||
| GET: `/api/User/profile/{userId}` | ||||||||||||||||||||||||||||
| Description: Get user by id | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T23:04:42.634Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Delete current user | ||||||||||||||||||||||||||||
| Delete: `/api/User/profile/{userId}` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Update User | ||||||||||||||||||||||||||||
| POST: `/api/User/profile/update/{userId}` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Request** | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "name": "string", | ||||||||||||||||||||||||||||
| "email": "string", | ||||||||||||||||||||||||||||
| "lastSeen": "2025-09-06T23:10:21.411Z", | ||||||||||||||||||||||||||||
| "bio": "string", | ||||||||||||||||||||||||||||
| "avatarPath": "string", | ||||||||||||||||||||||||||||
| "followerCount": 0 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Follow | ||||||||||||||||||||||||||||
| POST: `/api/User/profile/{followerId}/follow/{targetUserId}` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Unfollow | ||||||||||||||||||||||||||||
| POST: `/api/User/profile/{followerId}/unfollow/{targetUserId}` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| --------- | ||||||||||||||||||||||||||||
| ### Update Password | ||||||||||||||||||||||||||||
| GET: `/api/User/profile/update/pass/{userId}` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Request** | ||||||||||||||||||||||||||||
| ```json | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| "currentPassword": "string", | ||||||||||||||||||||||||||||
| "updatedPassword": "string" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
Comment on lines
+93
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method mismatch: docs show GET but code uses POST for Update Password. Align with controller. -### Update Password
-GET: `/api/User/profile/update/pass/{userId}`
+### Update Password
+POST: `/api/User/profile/update/pass/{userId}`📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.17.2)96-96: Horizontal rule style (MD035, hr-style) 101-101: Emphasis used instead of a heading (MD036, no-emphasis-as-heading) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Response** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Status Code: 200 | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,7 +56,7 @@ public async Task<IActionResult> Login(LoginDTO login) | |||||||||||||||||
| return Ok(result); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| [HttpGet] | ||||||||||||||||||
| [HttpPost] | ||||||||||||||||||
| [Route("refresh-token/{id}")] | ||||||||||||||||||
| [Authorize(AuthenticationSchemes = "Bearer")] | ||||||||||||||||||
| public async Task<IActionResult> RefreshToken(int id) | ||||||||||||||||||
|
Comment on lines
+59
to
62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refresh endpoint requires [Authorize], defeating refresh when access token is expired. Either make this action anonymous (recommended) or document that an unexpired access token is required (which undermines refresh UX). - [HttpPost]
- [Route("refresh-token/{id}")]
- [Authorize(AuthenticationSchemes = "Bearer")]
+ [HttpPost]
+ [Route("refresh-token/{id}")]
+ [AllowAnonymous]
public async Task<IActionResult> RefreshToken(int id)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,7 +72,7 @@ public async Task<IActionResult> UpdateUserAsync(int userId, UpdateUserDTO updat | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var userRead = await _userService.GetUserByIdAsync(userId); | ||||||||||||||||||||||||
| return Ok(userRead); | ||||||||||||||||||||||||
| return Ok(userRead.Data); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
74
to
76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Return only the inner payload — also handle post-update read failures. Good switch to returning - var userRead = await _userService.GetUserByIdAsync(userId);
- return Ok(userRead.Data);
+ var userRead = await _userService.GetUserByIdAsync(userId);
+ if (!userRead.success || userRead.Data is null)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, "Failed to load updated user.");
+ }
+ return Ok(userRead.Data);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| [HttpDelete] | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
Fix “passwrod” typo in request body.
User-facing docs.
📝 Committable suggestion
🤖 Prompt for AI Agents