예제 #1
0
 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'])));
 }
예제 #2
0
 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)));
 }