feat: Implement support chat functionality, add 2FA verification screen and routing, and update dependencies.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user