private function sendUserResetCode(User $user)
 {
     $fullname = $user->getFullname();
     $email = $user->getEmail();
     $code = $user->getVerificationCode();
     $message = "Dear   {$fullname}, <br> " . "\t The account verification code requested by you as be sent , please if this is you continue with the process. " . "<br>Account email : {$email}<br><br> " . "<br>Reset code : {$code}<br><br>" . "Copy and paste the reset code on the field provided in your application screen ";
     // send the code to the user throw email or text message
     $mailer = new TrySendEmail($message, ADMINISTRATOR_EMAIL, $email, $fullname);
     return $mailer->update();
 }
 private function createLoginDetailsFrom($email, $vcode, $newpassword)
 {
     $response = array();
     $response["success"] = 0;
     $tryFetchUser = new TryFetchUser();
     $dbuser = $tryFetchUser->fetch($email);
     if ($dbuser != null) {
         $php_user = new User(json_encode($dbuser));
         if (trim($php_user->getVerificationCode()) == trim($vcode)) {
             //create the new user login details
             //check if the user login details account already exists or created
             $tryCreateLogin = new TryCreateLoginDetail($php_user->getId(), $newpassword);
             if (!$tryCreateLogin->isExists()) {
                 if ($this->validate($newpassword)) {
                     if ($tryCreateLogin->create()) {
                         $response["success"] = 1;
                     } else {
                         //This should never happen
                         $response["error_message"] = "Error occur during login details creations";
                     }
                 } else {
                     $response["error_message"] = "Password characters must be more than 3";
                 }
             } else {
                 $response["error_message"] = "This account has already be verified";
             }
         } else {
             $response["error_message"] = "Invalid verification code provided";
         }
     } else {
         $response["error_message"] = "No account found with the given details";
     }
     $jsonView = new JsonViewer();
     $jsonView->setContent($response);
     return $jsonView;
 }
 private function sendWelcomeMessage($json)
 {
     $user = new User($json);
     if ($user != null) {
         $fullname = $user->getFullname();
         $code = $user->getVerificationCode();
         $email = $user->getEmail();
         $message = "Dear  {$fullname}, \n\t Thanks for register with DFinder , we intend to bring you new events around the world to you.\n" . "The DEvents is a social application that search events around in your location  with just a clicked.\n" . "\n <br> " . "Below is your username and password" . "<br>" . "Username = {$email}<br>" . "Verification code: = {$code}" . "\n<br>" . "To verify your account you need to copy the above given code below and paste it on the field at your screen\n<br>";
         $from = "*****@*****.**";
         $to = $email;
         $name = $fullname;
         $subject = "DFinder account creation confirmation details";
         $trysent = new TrySendEmail($message, $from, $to, $name, $subject);
         $trysent->update();
     }
 }