verifyNewEmailOTP method
Step 4:Verify OTP for new email and complete change
Implementation
Future<Map<String, dynamic>> verifyNewEmailOTP({
required String tenantId,
required String email,
required String otp,
}) async {
const query = r'''
mutation VerifyNewEmailOTP($input: EmailChangeInput!) {
verifyNewEmailOTP(input: $input) {
success
message
tenantUser {
id
username
email
}
}
}
''';
try {
final res = await _api.graphql(query, {
'input': {
'tenantID': tenantId,
'email': email,
'otp': otp,
}
});
final data = res['verifyNewEmailOTP'];
if (data == null) {
return {
'success': false,
'message': 'No data returned from server',
};
}
return Map<String, dynamic>.from(data);
} catch (e) {
print(" ERROR verifying new email OTP: $e");
return {
'success': false,
'message': 'Failed to verify OTP: $e',
};
}
}