Merge remote-tracking branch 'origin/dev' into cody/netwrok_SDK
# Conflicts: # apps/im_app/lib/features/chat/presentation/chat_db_test_view_model.dart # apps/im_app/lib/features/login/presentation/login_view_model.dart 修复逻辑漏洞,性能优化
This commit is contained in:
@@ -27,21 +27,25 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
final NetworksSdkApi _client;
|
||||
final void Function(String?) _onTokenUpdate;
|
||||
|
||||
AuthRepositoryImpl({required NetworksSdkApi client, required void Function(String?) onTokenUpdate,}) : _client = client, _onTokenUpdate = onTokenUpdate;
|
||||
AuthRepositoryImpl({
|
||||
required NetworksSdkApi client,
|
||||
required void Function(String?) onTokenUpdate,
|
||||
}) : _client = client,
|
||||
_onTokenUpdate = onTokenUpdate;
|
||||
|
||||
@override
|
||||
Future<User> login({required String email, required String password,}) async
|
||||
{
|
||||
final LoginData? loginData = await _client.executeRequest(LoginRequest(email: email, password: password),);
|
||||
Future<User> login({required String email, required String password}) async {
|
||||
final LoginResponse? loginResponse = await _client.executeRequest(
|
||||
LoginRequest(email: email, password: password),
|
||||
);
|
||||
|
||||
if (loginData == null) {
|
||||
throw Exception('Login failed: empty response'); // TODO: 接入国际化
|
||||
if (loginResponse == null) {
|
||||
throw Exception('Login failed: empty response');
|
||||
}
|
||||
|
||||
// 回调写入 Token(内存 + 持久化由 Provider 层组合)
|
||||
_onTokenUpdate(loginData.token);
|
||||
_onTokenUpdate(loginResponse.data.accessToken);
|
||||
|
||||
return loginData.toEntity(); // DTO → Domain Entity
|
||||
return loginResponse.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user