예제 #1
0
function addNewAccount($email, $nickname, $pwdHash)
{
    try {
        $existingAccount = da_account::GetAccount($email);
        if ($existingAccount->email == $email) {
            $response->status = "ERROR";
            $response->message = "Ya existe una cuenta de pvCloud para esa direccion de email ({$email})";
        } else {
            $newAccount = da_account::AddNewAccount($email, $nickname, $pwdHash);
            if ($newAccount != NULL && $newAccount->email == $email) {
                $response->status = "OK";
                $response->message = "Account for {$newAccount->email} was created successfully.";
            } else {
                $response->status = "EXCEPTION";
                $response->message = "Adding new account failed";
            }
        }
    } catch (Exception $ex) {
        $response->status = "EXCEPTION";
        $response->message = $ex->getMessage();
    }
    try {
        sendNewAccountEmail($newAccount->email, $newAccount->confirmation_guid);
    } catch (Exception $ex) {
    }
    return $response;
}
예제 #2
0
 public static function AddRequest($requester_account_id, $requested_account_id)
 {
     $sqlCommand = "INSERT INTO accounts_network(requester_account_id, requested_account_id, created_datetime)" . "VALUES (?,?, NOW())";
     $paramTypeSpec = "ii";
     $mysqli = DA_Helper::mysqli_connect();
     if ($mysqli->connect_errno) {
         $msg = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!($stmt = $mysqli->prepare($sqlCommand))) {
         $msg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->bind_param($paramTypeSpec, $requester_account_id, $requested_account_id)) {
         $msg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->execute()) {
         $msg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     $stmt->close();
     $insertedID = $mysqli->insert_id;
     $retrievedRecord = da_account::GetAccountNetworkEntry($insertedID);
     return $retrievedRecord;
 }
예제 #3
0
 /**
  * 
  * @return be_session
  */
 public static function DoLogin()
 {
     try {
         $parameters = LoginWebService::collectParameters();
         if (LoginWebService::parametersAreValid($parameters)) {
             $account = da_account::GetAccount($parameters->email);
             $response = LoginWebService::authenticationResult($account, $parameters);
         } else {
             $response->status = "Error";
             $response->message = "Parámetros Inválidos";
         }
     } catch (Exception $ex) {
         $response->status = "EXCEPTION";
         $response->message = $ex->getMessage();
     }
     return $response;
 }
 public static function PasswordRecovery_Execute()
 {
     $response = new WebServiceClass();
     try {
         $parameters = WebServiceClass::collectParameters();
         $account = da_account::GetAccountByID($parameters->AccountID);
         if ($account != NULL) {
             if ($account->email != "" && $parameters->Email == $account->email) {
                 if ($account->confirmation_guid == $parameters->ConfirmationCode) {
                     $accountModificationTime = new DateTime($account->modified_datetime);
                     $currentDateTime = new DateTime(DA_Helper::GetServerDate());
                     $difference = $currentDateTime->diff($accountModificationTime);
                     if ($difference->d == 0) {
                         $account->pwd_hash = sha1($parameters->Password);
                         $savedAccount = da_account::UpdateAccount($account);
                         if ($savedAccount != NULL && $savedAccount->account_id == $account->account_id) {
                             $response->status = "OK";
                             $response->message = "Contraseña Actualizada Satisfactoriamente";
                             WebServiceClass::sendPWRecoveryEmail($account);
                         } else {
                             $response->status = "ERROR";
                             $response->message = "Solicitud Inválida";
                         }
                     } else {
                         $response->status = "ERROR";
                         $response->message = "Solicitud Expirada";
                     }
                 } else {
                     $response->status = "ERROR";
                     $response->message = "Solicitud Inválida";
                 }
             } else {
                 $response->status = "ERROR";
                 $response->message = "Solicitud Inválida";
             }
         } else {
             $response->status = "ERROR";
             $response->message = "Solicitud Inválida";
         }
     } catch (Exception $ex) {
         $response->status = "EXCEPTION";
         $response->message = $ex->getMessage();
     }
     return $response;
 }
 public static function PasswordRecovery()
 {
     $response = new WebServiceClass();
     try {
         $confirmationID = uniqid();
         $parameters = WebServiceClass::collectParameters();
         $account = da_account::GetAccount($parameters->email);
         $account->confirmation_guid = $confirmationID;
         $savedAccount = da_account::UpdateAccount($account);
         WebServiceClass::sendPWRecoveryEmail($savedAccount);
         $response->status = "OK";
         $response->message = "Solicitud de recuperación de clave tramitada.";
     } catch (Exception $ex) {
         $response->status = "EXCEPTION";
         $response->message = $ex->getMessage();
     }
     return $response;
 }
 public static function ChangePassword()
 {
     $response = new WebServiceClass();
     try {
         $account_id = NULL;
         // Session Validation INCLUDE will populate this variable
         include './inc/incWebServiceSessionValidation.php';
         $parameters = WebServiceClass::collectParameters();
         /**
          * @var be_account
          */
         $activatedAccount = da_account::GetAccountByID($account_id);
         $currentPasswordHash = sha1($parameters->old_password);
         $oldPasswordHash = $activatedAccount->pwd_hash;
         $newPasswordHash = sha1($parameters->new_password);
         $parameters->ophash = $oldPasswordHash;
         $parameters->cphash = $currentPasswordHash;
         $parameters->nphash = $newPasswordHash;
         $parameters->account = $activatedAccount;
         $parameters->account_id = $account_id;
         if ($currentPasswordHash == $oldPasswordHash) {
             $activatedAccount->pwd_hash = $newPasswordHash;
             $savedAccount = da_account::UpdateAccount($activatedAccount);
             $parameters->savedAccount = $savedAccount;
             if ($savedAccount->pwd_hash == $activatedAccount->pwd_hash) {
                 $response->status = "OK";
                 $response->message = "Clave fue cambiada exitosamente";
             } else {
                 $response->status = "ERROR";
                 $response->data = $parameters;
                 $response->message = "Ocurrió un error inesperado al guardar la nueva clave";
             }
         } else {
             $response->status = "ERROR";
             $response->message = "Clave actual incorrecta";
             $response->data = $parameters;
         }
     } catch (Exception $ex) {
         $response->status = "EXCEPTION";
         $response->message = $ex->getMessage();
     }
     return $response;
 }
예제 #7
0
/* * *
 * http://localhost:8080/pvcloud/backend/new_account.php?email=jose.a.nunez@gmail.com&nickname=jose&pwdHash=1234pass
 * 
 * * */
error_reporting(E_ERROR);
class newAccountResponse
{
    public $status = "";
    public $message = "";
}
require_once './DA/da_conf.php';
require_once './DA/da_helper.php';
require_once './DA/da_account.php';
$email = filter_input(INPUT_GET, "email");
$guid = filter_input(INPUT_GET, "guid");
$response = new newAccountResponse();
try {
    $activatedAccount = da_account::ActivateAccount($email, $guid);
    if ($activatedAccount != NULL && $activatedAccount->email == $email && $activatedAccount->confirmed == TRUE) {
        $response->status = "OK";
        $response->message = "Account for {$email} was confirmed successfully.";
    } else {
        $response->status = "ERROR";
        $response->message = "Account Confirmation failed";
    }
} catch (Exception $ex) {
    $response->status = "ERROR";
    $response->message = $ex->getMessage();
}
include './inc/incJSONHeaders.php';
echo json_encode($response);
예제 #8
0
function test_da_account()
{
    $createdAccount = da_account::AddNewAccount("*****@*****.**", "neo", sha1("sion"));
    if ($createdAccount == NULL) {
        echo "ERROR";
    } else {
        echo "OK<br>";
        print_r($createdAccount);
    }
}
예제 #9
0
 /**
  * Updates the data of an account
  * @param be_account $account
  * @return be_account
  */
 public static function UpdateAccount($account)
 {
     $sqlCommand = "UPDATE accounts " . " SET confirmation_guid = ?," . " confirmed = ?," . " deleted_datetime = ?," . " email = ?," . " nickname = ?," . " pwd_hash = ?" . " WHERE account_id = ? ";
     $paramTypeSpec = "sissssi";
     $mysqli = DA_Helper::mysqli_connect();
     if ($mysqli->connect_errno) {
         $msg = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
         throw new Exception($msg, $mysqli->connect_errno);
     }
     if (!($stmt = $mysqli->prepare($sqlCommand))) {
         $msg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->bind_param($paramTypeSpec, $account->confirmation_guid, $account->confirmed, $account->deleted_datetime, $account->email, $account->nickname, $account->pwd_hash, $account->account_id)) {
         $msg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     if (!$stmt->execute()) {
         $msg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
         throw new Exception($msg, $stmt->errno);
     }
     $stmt->close();
     $savedAccount = da_account::GetAccount($account->email);
     return $savedAccount;
 }