Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/src/api/chat/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const postLogin = (loginRequest: ChatLoginRequest, accessToken?: string, savedTo
/** 使用 LDAP 账号登录;传入 accessToken 时登录到对应应用,否则登录门户。携带本地保存的 token。 */
const postLdapLogin = (loginRequest: ChatLoginRequest, accessToken?: string, savedToken?: string) => {
return promise<ChatLoginResponse>(
request.post<ApiResponse<ChatLoginResponse>>(accessToken ? `/auth/ldap/login/${accessToken}` : '/auth/ldap/login', loginRequest, {
request.post<ApiResponse<ChatLoginResponse>>('/auth/ldap/login', loginRequest, {
params: accessToken ? { accessToken } : undefined,
headers: getSavedTokenHeaders(savedToken),
}),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues / Observations:

  1. API contract change (breaking): The endpoint path changed from /auth/ldap/login/${accessToken} to a fixed /auth/ldap/login with accessToken moved into query params. Ensure the backend actually supports the query-param variant; otherwise this is a behavioral regression.

  2. Potential inconsistency with postLogin: If the sibling postLogin still uses the path-segment pattern, the two login functions now diverge in how they pass accessToken. Verify this divergence is intentional.

  3. Undefined params: Passing params: undefined is generally harmless in axios, but some wrappers/interceptors may not handle it consistently. Prefer building the config object conditionally or letting the library ignore it (usually fine).

  4. Semantic/security concern: Moving an access token from path to query string does not materially change exposure (both are logged), but query strings are more commonly logged by proxies/servers. Confirm logging policies.

  5. Type safety: No explicit typing on the new params object; minor, but consider typing for consistency.

Optimization suggestion: Use a spread/conditional to avoid passing undefined:

request.post<ApiResponse<ChatLoginResponse>>('/auth/ldap/login', loginRequest, {
  ...(accessToken ? { params: { accessToken } } : {}),
  headers: getSavedTokenHeaders(savedToken),
})

Also add/update a unit test asserting the correct URL + params for both cases (with and without accessToken).

Expand Down
Loading