public function SendPassword($username = "") { $users = Users::find('first', array('conditions' => array('username' => $username))); $id = (string) $users['_id']; if ($id == "") { return $this->render(array('json' => array("Password" => "Password Not sent", "TOTP" => "No"))); } $ga = new GoogleAuthenticator(); $secret = $ga->createSecret(64); $details = Details::find('first', array('conditions' => array('username' => $username, 'user_id' => (string) $id))); if ($details['oneCodeused'] == 'Yes' || $details['oneCodeused'] == "") { $oneCode = $ga->getCode($secret); $data = array('oneCode' => $oneCode, 'oneCodeused' => 'No'); $details = Details::find('all', array('conditions' => array('username' => $username, 'user_id' => (string) $id)))->save($data); } $details = Details::find('first', array('conditions' => array('username' => $username, 'user_id' => (string) $id))); $oneCode = $details['oneCode']; $totp = "No"; if ($details['TOTP.Validate'] == true && $details['TOTP.Login'] == true) { $totp = "Yes"; } if ($details['EmailPasswordSecurity'] == "true" || $details['EmailPasswordSecurity'] == null) { $view = new View(array('loader' => 'File', 'renderer' => 'File', 'paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php'))); $email = $users['email']; $body = $view->render('template', compact('users', 'oneCode', 'username'), array('controller' => 'users', 'template' => 'onecode', 'type' => 'mail', 'layout' => false)); $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance(); $message->setSubject("Sign in password for " . COMPANY_URL); $message->setFrom(array(NOREPLY => 'Sign in password from ' . COMPANY_URL)); $message->setTo($email); $message->setBody($body, 'text/html'); $mailer->send($message); } return $this->render(array('json' => array("Password" => "Password sent to email", "TOTP" => $totp, "EmailPasswordSecurity" => $details['EmailPasswordSecurity']))); }
public function register() { if (!$this->request->query['UserName']) { return $this->render(array('json' => array("Error" => "Username not specified"))); } if (!$this->request->query['FirstName']) { return $this->render(array('json' => array("Error" => "Firstname not specified"))); } if (!$this->request->query['LastName']) { return $this->render(array('json' => array("Error" => "Lastname not specified"))); } if (!$this->request->query['Email']) { return $this->render(array('json' => array("Error" => "Email not specified"))); } if (!$this->request->query['Password']) { return $this->render(array('json' => array("Error" => "Password not specified"))); } $uuid = new Uuid(); $ga = new GoogleAuthenticator(); $xemail = $uuid->hashme($this->request->query['Email']); $xwalletid = $uuid->hashme($this->request->query['Walletid']); $data = array('username' => $this->request->query['UserName'], 'firstname' => $this->request->query['FirstName'], 'lastname' => $this->request->query['LastName'], 'email' => $this->request->query['Email'], 'password' => password_hash($this->request->query['Password'], PASSWORD_BCRYPT), 'walletid' => $this->request->query['Walletid']); $Users = Users::create($data); $saved = $Users->save(); if ($saved == true) { $verification = sha1($Users->_id); $data = array('user_id' => (string) $Users->_id, 'username' => (string) $Users->username, 'email.verify' => $verification, 'email.verified' => "No", 'mobile.verified' => "No", 'mobile.number' => "", 'key' => $ga->createSecret(64), 'secret' => $ga->createSecret(64), 'walletid' => $this->request->query['Walletid']); Details::create()->save($data); } else { return $this->render(array('json' => array("success" => 0))); } $xmain_email = $uuid->hashme(MAIN_EMAIL); $xescrow_email = $uuid->hashme(ESCROW_EMAIL); return $this->render(array('json' => array("success" => 1, "xemail" => $xemail, "xwalletid" => $xwalletid, "recordid" => (string) $Users->_id, "main_email" => MAIN_EMAIL, "escrow_email" => ESCROW_EMAIL, "xmain_email" => $xmain_email, "xescrow_email" => $xescrow_email))); }
public function sendPasswordPhone() { $walletid = $this->request->query['walletid']; $ga = new GoogleAuthenticator(); $secret = $ga->createSecret(64); $details = Details::find('first', array('conditions' => array('walletid' => $walletid))); if ($details['signinCodeused'] == 'Yes' || $details['signinCodeused'] == "") { $signinCode = $ga->getCode($secret); $data = array('signinCode' => $signinCode, 'signinCodeused' => 'No'); $details = Details::find('all', array('conditions' => array('walletid' => $walletid)))->save($data); } $details = Details::find('first', array('conditions' => array('walletid' => $walletid))); $function = new Functions(); $users = Users::find('first', array('conditions' => array('walletid' => $walletid))); $phone = $users['phone']; if (substr($phone, 0, 1) == '+') { $phone = str_replace("+", "", $phone); } $signinCode = $details['signinCode']; $msg = 'Please enter XGCWallet sign in password: '******' on the login page.'; $returnvalues = $function->twilio($phone, $msg, $signinCode); // Testing if it works return $this->render(array('json' => array('success' => 1))); }