Skip to content

Commit 4e88f60

Browse files
committed
fix: handle legacy API response format in signIn method
1 parent 4d8038b commit 4e88f60

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/api/auth.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,22 @@ class AuthApi {
2828
}
2929

3030
final data = result.getOrThrow().data;
31+
final finalData = data['data'] ?? data;
32+
// NOTE: Legacy API responses may not include 'data' wrapper, handle both formats
33+
3134
await cookieManager.setCookie(
3235
url: WebUri.uri(result.getOrThrow().requestOptions.uri),
3336
name: 'cw_d_session_info',
3437
value: Uri.encodeComponent(jsonEncode(result.getOrThrow().headers.map)),
3538
);
3639

37-
return ProfileInfo.fromJson(data).toSuccess();
40+
return ProfileInfo.fromJson(finalData).toSuccess();
3841
}
3942

40-
Future<Result<String>> resetPassword({
41-
required String email,
42-
}) async {
43+
Future<Result<String>> resetPassword({required String email}) async {
4344
final path = '${service.baseUrl.value}/auth/password';
4445

45-
final result = await service.post<String>(
46-
path,
47-
data: {'email': email},
48-
);
46+
final result = await service.post<String>(path, data: {'email': email});
4947
if (result.isError()) {
5048
return result.exceptionOrNull()!.toFailure();
5149
}

0 commit comments

Comments
 (0)