IA-941 : fix(auth): resolve login token extraction and 401 interceptor loop
Problem
Login was completely broken for parent mobile app users. Three compounding bugs caused the failure:
- The 401 response interceptor triggered
signOut()on failed login attempts, swallowing the real error and returningundefinedinstead of a meaningful message. - Token extraction assumed
response.data.tokenexclusively, breaking compatibility with APIs returningaccess_token,accessToken, or nesteddata.token. - Debug logs were placed inside
forgotPasswordinstead ofsignInWithPassword, making the issue impossible to diagnose.
Changes
-
Interceptor fix: Exclude the login endpoint from the 401 handler so failed
credentials return a proper error instead of silently calling
signOut() -
Token extraction: Support multiple response formats (
token,access_token,accessToken,data.token,data.access_token) -
Error logging: Replaced partial
error.response?.data?.messagelog with full error object (message, code, status, data) for future debugging -
Debug logs: Moved
URLandRESPONSE DATAlogs to the correct function