예제 #1
0
 /**
  * Authenticate user by $username and $password
  *
  * @param Mage_User_Model_User $user
  * @return Mage_User_Model_Resource_User
  */
 public function recordLogin(Mage_User_Model_User $user)
 {
     $adapter = $this->_getWriteAdapter();
     $data = array('logdate' => now(), 'lognum' => $user->getLognum() + 1);
     $condition = array('user_id = ?' => (int) $user->getUserId());
     $adapter->update($this->getMainTable(), $data, $condition);
     return $this;
 }
예제 #2
0
 /**
  * @magentoDbIsolation enabled
  */
 public function testLoginsAreLogged()
 {
     $this->_model->loadByUsername(Magento_Test_Bootstrap::ADMIN_NAME);
     $lognum = $this->_model->getLognum();
     $beforeLogin = time();
     $this->_model->login(Magento_Test_Bootstrap::ADMIN_NAME, Magento_Test_Bootstrap::ADMIN_PASSWORD)->reload();
     $loginTime = strtotime($this->_model->getLogdate());
     $this->assertTrue($beforeLogin <= $loginTime && $loginTime <= time());
     $this->assertEquals(++$lognum, $this->_model->getLognum());
     $beforeLogin = time();
     $this->_model->login(Magento_Test_Bootstrap::ADMIN_NAME, Magento_Test_Bootstrap::ADMIN_PASSWORD)->reload();
     $loginTime = strtotime($this->_model->getLogdate());
     $this->assertTrue($beforeLogin <= $loginTime && $loginTime <= time());
     $this->assertEquals(++$lognum, $this->_model->getLognum());
 }