optionUpdateEmail method

Future<Response> optionUpdateEmail()

Changes the e-mail of a user

Implementation

Future<Response> optionUpdateEmail() async {
  clear();
  print('Update e-mail:');
  try {
    askJWT();
    askEmail();
    var newEmail = prompts.get('New e-mail: ', defaultsTo: '');

    var response = await _userUC.updateEmail(_email, newEmail, _jwt);
    if (response.statusCode == 400) {
      _response = 'response: ${response.statusCode}';
      return response;
    } else {
      _email = newEmail;
      _jwt = response.body;
      _response = 'response: ${response.body}';
      return response;
    }
  } catch (e) {
    _response = e.toString();
    throw ('updateEmail');
  }
}