$hash = hash_pbkdf2("sha512", $password, $salt, 262144); $emailActivation = bin2hex(random_bytes(16)); //create new user $user = new User(null, $_SESSION["company"]->getCompanyId(), $requestObject->userCrewId, $requestObject->userAccessId, $requestObject->userPhone, $requestObject->userFirstName, $requestObject->userLastName, $requestObject->userEmail, $emailActivation, $hash, $salt); $user->insert($pdo); //building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account. $basePath = dirname($_SERVER["SCRIPT_NAME"], 4); $urlglue = $basePath . "/activation/?emailActivation=" . $user->getUserActivation(); $confirmLink = "https://" . $_SERVER["SERVER_NAME"] . $urlglue; $messageSubject = "This is an important message about your account activation."; $message = <<<EOF <h1>You've been registered for the Timecrunchers Scheduling!</h1> <p>Visit the following URL to set a new password and complete the registration process: </p> <p><a href="{$confirmLink}">{$confirmLink}</a></p> EOF; $response = sendEmail($user->getUserEmail(), $user->getUserFirstName(), $user->getUserLastName(), $messageSubject, $message); if ($response === "Email sent.") { $reply->message = "sign up was successful, please check your email for activation message."; } /** * the send method returns the number of recipients that accepted the Email * so, if the number attempted is not the number accepted, this is an Exception **/ } } } else { if ($method === "DELETE") { $reply->debug = "delete started"; $user = User::getUserByUserId($pdo, $id); if ($user === null) { throw new RuntimeException("User does not exist", 404);