示例#1
0
 public function testGetValidateHash()
 {
     $password = uniqid();
     $hash = $this->_helper->getHash($password);
     $this->assertTrue(is_string($hash));
     $this->assertTrue($this->_helper->validateHash($password, $hash));
 }
示例#2
0
文件: Url.php 项目: nemphys/magento2
 /**
  * Generate secret key for controller and action based on form key
  *
  * @param string $routeName
  * @param string $controller Controller name
  * @param string $action Action name
  * @return string
  */
 public function getSecretKey($routeName = null, $controller = null, $action = null)
 {
     $salt = $this->_coreSession->getFormKey();
     $request = $this->getRequest();
     if (!$routeName) {
         if ($request->getBeforeForwardInfo('route_name') !== null) {
             $routeName = $request->getBeforeForwardInfo('route_name');
         } else {
             $routeName = $request->getRouteName();
         }
     }
     if (!$controller) {
         if ($request->getBeforeForwardInfo('controller_name') !== null) {
             $controller = $request->getBeforeForwardInfo('controller_name');
         } else {
             $controller = $request->getControllerName();
         }
     }
     if (!$action) {
         if ($request->getBeforeForwardInfo('action_name') !== null) {
             $action = $request->getBeforeForwardInfo('action_name');
         } else {
             $action = $request->getActionName();
         }
     }
     $secret = $routeName . $controller . $action . $salt;
     return $this->_coreHelper->getHash($secret);
 }
$t = $this->getTable('cms_block');
$conn->addColumn($t, 'udropship_vendor', 'int(11) unsigned');
$conn->addConstraint('FK_CMS_BLOCK_VENDOR', $t, 'udropship_vendor', $vt, 'vendor_id');
*/
$t = $this->getTable('admin_user');
$conn->modifyColumn($t, 'username', 'varchar(128) NOT NULL DEFAULT \'\'');
$conn->addColumn($t, 'udropship_vendor', 'int(11) unsigned');
$conn->addConstraint('FK_ADMIN_USER_VENDOR', $t, 'udropship_vendor', $vt, 'vendor_id');
$t = $this->getTable('admin_role');
$roleId = $conn->fetchOne("select role_id from {$t} where role_name='Dropship Vendor'");
if (!$roleId) {
    $conn->insert($t, array('tree_level' => 1, 'role_type' => 'G', 'role_name' => 'Dropship Vendor'));
    $roleId = $conn->lastInsertId($t);
    $rules = new Mage_Admin_Model_Rules();
    $rules->setResources(array('admin/catalog', 'admin/catalog/products'));
    $rules->setRoleId($roleId)->saveRel();
}
$ut = $this->getTable('admin_user');
$vendors = $conn->fetchAll("select * from {$this->getTable('udropship_vendor')}");
$coreHlp = new Mage_Core_Helper_Data();
foreach ($vendors as $v) {
    if ($conn->fetchOne("select user_id from {$ut} where username=?", $v['email'])) {
        continue;
    }
    $conn->insert($ut, array('firstname' => $v['vendor_name'], 'lastname' => $v['vendor_attn'], 'email' => $v['email'], 'username' => $v['email'], 'password' => $coreHlp->getHash($v['password'], 2), 'created' => now(), 'is_active' => 1, 'udropship_vendor' => $v['vendor_id']));
    $userId = $conn->lastInsertId($ut);
    $conn->insert($t, array('parent_id' => $roleId, 'tree_level' => 2, 'role_type' => 'U', 'user_id' => $userId, 'role_name' => $v['vendor_name']));
}
$this->run("\nCREATE TABLE IF NOT EXISTS `{$this->getTable('udropship_vendor_registration')}`  (\n`reg_id` int(10) unsigned NOT NULL auto_increment,\n`store_id` smallint(5) unsigned NOT NULL,\n`vendor_name` varchar(255) default NULL,\n`telephone` varchar(255) default NULL,\n`email` varchar(255) default NULL,\n`password_enc` varchar(255) default NULL,\n`password_hash` varchar(255) default NULL,\n`carrier_code` varchar(64) default NULL,\n`vendor_attn` varchar(255) default NULL,\n`street` text,\n`city` varchar(255) default NULL,\n`zip` varchar(255) default NULL,\n`region_id` int(10) unsigned default NULL,\n`region` varchar(255) default NULL,\n`country_id` char(2) default NULL,\n`remote_ip` varchar(15) default NULL,\n`registered_at` datetime default NULL,\n`url_key` varchar(64) default NULL,\n`comments` text,\n`notes` text,\nPRIMARY KEY  (`reg_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n");
$this->endSetup();