Kris20030907 opened a new issue, #491:
URL: https://github.com/apache/rocketmq-dashboard/issues/491

   ## Background
   
   The login API contract used by the RocketMQ Studio frontend does not match 
the response returned by the backend.
   
   The backend returns the following structure from `POST /api/auth/login`:
   
   ```json
   {
     "code": 200,
     "message": "success",
     "data": {
       "token": "mock-jwt-...",
       "expiresIn": 86400,
       "user": {
         "username": "admin",
         "admin": true
       }
     }
   }
   ```
   
   However, the frontend currently declares and consumes `username` and `role` 
as top-level fields of `data`.
   
   ## Steps to reproduce
   
   1. Start the RocketMQ Studio backend and frontend.
   2. Submit any non-empty username and password on the login page.
   3. The backend responds with HTTP 200 and the nested `data.user` object.
   4. Inspect the frontend authentication state or browser storage after login.
   
   ## Actual behavior
   
   - The frontend passes `data.username`, which is `undefined`, to the 
authentication store.
   - The frontend writes the missing `data.role` value to the unused `userrole` 
storage key.
   - The current frontend API test uses a response shape that differs from the 
backend, so it does not detect the integration problem.
   
   ## Expected behavior
   
   - The frontend login response type should match the backend `LoginVO` 
contract.
   - The authentication store should receive `data.user.username`.
   - Frontend tests should use the actual backend response structure.
   - The unused and invalid `userrole` value should not be written.
   
   ## Proposed change
   
   - Update the frontend `LoginResponse` type to include `expiresIn` and nested 
`user` fields.
   - Read the username from `data.user.username` after a successful login.
   - Remove the unused `userrole` storage write.
   - Update the Auth API test to cover the backend response contract.
   
   ## Scope
   
   This issue only fixes the frontend/backend response contract mismatch. 
Implementing real authentication, token verification, authorization, or session 
expiration is outside its scope.
   
   ## Acceptance criteria
   
   - A successful login stores the username returned in `data.user.username`.
   - The frontend no longer reads nonexistent top-level `username` or `role` 
fields.
   - The frontend Auth API test uses the same response shape as the backend 
controller test.
   - Relevant frontend tests and type checks pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to