dcash_wallet/wallet.cpp
string auth(HttpClient *client, string username, string password, string email) {
  client->set_basic_auth(username, password);
  WwwFormEncodedDict encoder = WwwFormEncodedDict();
  encoder.set("username", username); 
  encoder.set("password", password);
  string body = encoder.encode();

  HTTPClientResponse *response;
  response = client->post("/auth-tokens", body);
  string rsp = response->body();
  bool success = response->success();
  delete response;

  if (!success) {
    throw "HTTP Client Response Failed.";
  }

  Document d;
  d.Parse(rsp);
  assert(d["auth_token"].IsString());
  assert(d["user_id"].IsString());
  auth_token = d["auth_token"].GetString();
  user_id = d["user_id"].GetString();
  
  is_loged_in = true;
  return update_email(email);
}
/**
 * @brief Authenticated a user.
 * If the username doesn't exist this call will create a new user, 
 * and if it does exist then it logs in the user if the password matches.
 * 
 * @param client Http client to the API server.
 * @param username The user's username.
 * @param password The user's password.
 * @param email The user's email.
 * @return string The user's current balance.
 */
@brief Authenticated a user.
If the username doesn't exist this call will create a new user,
and if it does exist then it logs in the user if the password matches.

@param client Http client to the API server.
@param username The user's username.
@param password The user's password.
@param email The user's email.
@return string The user's current balance.
@brief Authenticated a user . If the username doesn ' t exist this call will create a new user and if it does exist then it logs in the user if the password matches . @param client Http client to the API server . @param username The user ' s username . @param password The user ' s password . @param email The user ' s email . @return string The user ' s current balance .
string auth(HttpClient *client, string username, string password, string email) {
  client->set_basic_auth(username, password);
  WwwFormEncodedDict encoder = WwwFormEncodedDict();
  encoder.set("username", username); 
  encoder.set("password", password);
  string body = encoder.encode();
  HTTPClientResponse *response;
  response = client->post("/auth-tokens", body);
  string rsp = response->body();
  bool success = response->success();
  delete response;
  if (!success) {
    throw "HTTP Client Response Failed.";
  }
  Document d;
  d.Parse(rsp);
  assert(d["auth_token"].IsString());
  assert(d["user_id"].IsString());
  auth_token = d["auth_token"].GetString();
  user_id = d["user_id"].GetString();
  is_loged_in = true;
  return update_email(email);
}
string auth ( HttpClient * client , string username , string password , string email ) { client -> set_basic_auth ( username , password ) ; WwwFormEncodedDict encoder = WwwFormEncodedDict ( ) ; encoder . set ( " " , username ) ; encoder . set ( " " , password ) ; string body = encoder . encode ( ) ; HTTPClientResponse * response ; response = client -> post ( " " , body ) ; string rsp = response -> body ( ) ; bool success = response -> success ( ) ; delete response ; if ( ! success ) { throw " " ; } Document d ; d . Parse ( rsp ) ; assert ( d [ " " ] . IsString ( ) ) ; assert ( d [ " " ] . IsString ( ) ) ; auth_token = d [ " " ] . GetString ( ) ; user_id = d [ " " ] . GetString ( ) ; is_loged_in = true ; return update_email ( email ) ; }
@brief Authenticated a user.
@brief Authenticated a user .