コード例 #1
0
ファイル: Auth.php プロジェクト: kingsj/core
 /**
  * Logs in admin to cart.
  *
  * @param string $login    Administrator user login
  * @param string $password Administrator user password
  *
  * @return \XLite\Model\Profile
  */
 public function loginAdministrator($login, $password)
 {
     $profile = $this->login($login, $password);
     if ($profile instanceof \XLite\Model\Profile && !$profile->isAdmin()) {
         // Logoff user from session
         $this->logoff();
         // Reset profile object
         $profile = self::RESULT_ACCESS_DENIED;
         // Send notification about failed log in attempt
         \XLite\Core\Mailer::sendFailedAdminLoginNotification(\XLite\Core\Request::getInstance()->login);
     }
     return $profile;
 }
コード例 #2
0
ファイル: Mailer.php プロジェクト: kingsj/core
 /**
  * testSendFailedAdminLoginNotification
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testSendFailedAdminLoginNotification()
 {
     $profile = self::$admin_profile;
     $this->startCheckingMail();
     \XLite\Core\Mailer::sendFailedAdminLoginNotification(self::TESTER_EMAIL);
     sleep(3);
     $emails = $this->finishCheckingMail();
     if (empty($emails)) {
         $this->markTestSkipped('Email notification not found in the mail box');
     }
     $email = array_shift($emails);
     $result = (bool) preg_match('/Administrator login failure.*' . preg_quote(self::TESTER_EMAIL) . '/msS', $email['body']);
     $this->assertTrue($result, 'Check if email contents keywords');
 }