mfaBindPhone static method
mfa bind phone
Implementation
static Future<AuthResult> mfaBindPhone(String phoneNumber, String passCode,
[String? phoneCountryCode]) async {
Map map = {};
map.putIfAbsent('phoneNumber', () => phoneNumber);
if (phoneCountryCode != null) {
map.putIfAbsent('phoneCountryCode', () => phoneCountryCode);
}
var body = {
'factorType': 'SMS',
'profile': map,
};
var jsonBody = jsonEncode(body);
final Result tokenResult =
await post('/api/v3/send-enroll-factor-request', jsonBody);
if (tokenResult.statusCode == 200) {
var resultBody = {
'factorType': 'SMS',
'enrollmentToken': tokenResult.data['enrollmentToken'],
'enrollmentData': {'passCode': passCode}
};
final Result result =
await post('/api/v3/enroll-factor', jsonEncode(resultBody));
AuthResult authResult = AuthResult(result);
return authResult;
} else {
return AuthResult(tokenResult);
}
}