updateEmail static method
update current user's email address.
Implementation
static Future<AuthResult> updateEmail(
String newEmail, String newEmailPassCode,
[String? oldEmail, String? oldEmailPassCode]) async {
Map map = {};
map.putIfAbsent('newEmail', () => newEmail);
map.putIfAbsent('newEmailPassCode', () => newEmailPassCode);
if (oldEmail != null && oldEmailPassCode != null) {
map.putIfAbsent('oldEmail', () => oldEmail);
map.putIfAbsent('oldEmailCode', () => oldEmailPassCode);
}
var body = {'verifyMethod': 'EMAIL_PASSCODE', 'emailPassCodePayload': map};
final Result tokenResult =
await post('/api/v3/verify-update-email-request', jsonEncode(body));
if (tokenResult.statusCode == 200) {
final Result result = await post('/api/v3/update-email',
jsonEncode(tokenResult.data['updateEmailToken']));
AuthResult authResult = AuthResult(result);
return authResult;
} else {
return AuthResult(tokenResult);
}
}