feat: Implement support chat functionality, add 2FA verification screen and routing, and update dependencies.

This commit is contained in:
pradeepkumar
2026-03-11 13:26:16 +05:30
parent 4780eb9a63
commit 6928697c5c
17 changed files with 1660 additions and 20 deletions

View File

@@ -52,6 +52,58 @@ class AuthRepository {
}
}
/// Verify 2FA TOTP token during login
Future<AuthResponse> verifyTwoFactor({
required String tempToken,
required String token,
}) async {
try {
final response = await _dio.post(
ApiConstants.twoFactorVerify,
data: {'tempToken': tempToken, 'token': token},
);
final data = response.data['data'] as Map<String, dynamic>;
final authResponse = AuthResponse.fromJson(data);
await SecureStorage.saveTokens(
accessToken: authResponse.accessToken,
refreshToken: authResponse.refreshToken,
);
return authResponse;
} on DioException catch (e) {
if (e.error is ApiException) throw e.error as ApiException;
throw ApiException(
message: e.message ?? '2FA verification failed',
statusCode: e.response?.statusCode,
);
}
}
/// Verify backup code during login
Future<AuthResponse> verifyBackupCode({
required String tempToken,
required String backupCode,
}) async {
try {
final response = await _dio.post(
ApiConstants.twoFactorVerifyBackup,
data: {'tempToken': tempToken, 'backupCode': backupCode},
);
final data = response.data['data'] as Map<String, dynamic>;
final authResponse = AuthResponse.fromJson(data);
await SecureStorage.saveTokens(
accessToken: authResponse.accessToken,
refreshToken: authResponse.refreshToken,
);
return authResponse;
} on DioException catch (e) {
if (e.error is ApiException) throw e.error as ApiException;
throw ApiException(
message: e.message ?? 'Backup code verification failed',
statusCode: e.response?.statusCode,
);
}
}
Future<UserModel> getMe() async {
try {
final response = await _dio.get(ApiConstants.authMe);