本文整理汇总了PHP中BlowfishPasswordHasher类的典型用法代码示例。如果您正苦于以下问题:PHP BlowfishPasswordHasher类的具体用法?PHP BlowfishPasswordHasher怎么用?PHP BlowfishPasswordHasher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlowfishPasswordHasher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave($options = array())
{
// hash the password
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
// initially generate the url // generate default url if user_level_id is 10 or 20 in data
if (isset($this->data[$this->alias]['email'])) {
$this->data[$this->alias]['url'] = md5($this->data[$this->alias]['email']);
} else {
if (isset($this->data[$this->alias]['user_level_id']) && ($this->data[$this->alias]['user_level_id'] == 10 || $this->data[$this->alias]['user_level_id'] == 20)) {
$this->data[$this->alias]['url'] = md5(AuthComponent::user('email'));
}
}
//check if user has pre-url, prepend pre-url to url
if (isset($this->data[$this->alias]['pre_url'])) {
$this->data[$this->alias]['url'] = $this->data[$this->alias]['pre_url'] . "" . $this->data[$this->alias]['url'];
}
// check/set referral for user
App::uses('CakeSession', 'Model/Datasource');
$referral_id = CakeSession::read('referral');
if (!empty($referral_id)) {
$this->data[$this->alias]['referral_id'] = $referral_id;
CakeSession::delete('referral');
}
return true;
}
示例2: beforeSave
public function beforeSave($options = array())
{
$passwordHasher = new BlowfishPasswordHasher();
$this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
$this->log("beforesave" . $this->data['User']['password'], 'debug');
return true;
}
示例3: beforeFilter
public function beforeFilter()
{
if ($this->request->is('ajax')) {
$this->response->type("application/json");
$this->layout = "ajax";
} elseif ($this->request->params['controller'] != 'installers' && !$this->__isInstalled()) {
$this->redirect(array('controller' => 'installers', 'action' => 'index'));
} elseif ($this->request->params['controller'] == 'installers' && $this->__isInstalled()) {
$this->Session->setFlash(__('Sonerezh is already installed. Remove or rename app/Config/database.php to run the installation again.'), 'flash_info');
$this->redirect(array('controller' => 'songs', 'action' => 'index'));
}
if ($this->__isInstalled() && !$this->Auth->user() && $this->Cookie->check('auth')) {
$this->loadModel('User');
$cookie = $this->Cookie->read('auth');
$authCookie = explode(':', $cookie);
$user = $this->User->find('first', array('conditions' => array('id' => $authCookie[0])));
$passwordHasher = new BlowfishPasswordHasher();
if ($passwordHasher->check($user['User']['email'], $authCookie[1]) && $passwordHasher->check($user['User']['password'], $authCookie[2])) {
unset($user['User']['password']);
$this->Auth->login($user['User']);
$this->Cookie->write('auth', $this->Cookie->read('auth'));
} else {
$this->Cookie->delete('auth');
}
}
if (!$this->request->is('ajax') && $this->Auth->user()) {
$this->loadModel('Setting');
$setting = $this->Setting->find('first', array('fields' => array('sync_token')));
$this->set('sync_token', $setting['Setting']['sync_token']);
}
$this->__setLanguage();
}
示例4: comparePassword
public function comparePassword($id = null, $password = null)
{
$passwordHasher = new BlowfishPasswordHasher();
$this->id = $id;
$hashPasswordData = $this->field('password');
return $passwordHasher->check($password, $hashPasswordData);
}
示例5: add_api
public function add_api()
{
if ($this->request->is(array('post', 'xml')) && $this->request->data['Trade']['product_id'] > 0 && $this->request->data['Trade']['user_id'] > 0) {
$this->Trade->create();
$this->request->data['Trade']['validated'] = 0;
$this->Trade->Product->id = $this->request->data['Trade']['product_id'];
$this->Trade->User->id = $this->request->data['Trade']['user_id'];
$cost = $this->Trade->Product->field('points_value');
$user_total = $this->Trade->User->field('total_points');
$available = $this->Trade->Product->field('quantity_available');
if ($user_total > $cost && $this->Trade->save($this->request->data) && $available > 0) {
$this->Trade->User->saveField('total_points', $user_total - $cost);
$this->Trade->Product->saveField('quantity_available', $this->Trade->Product->field('quantity_available') - 1);
$qrCode = $this->Trade->id . $this->request->data['Trade']['user_id'] . $this->request->data['Trade']['product_id'] . $this->Trade->field('created');
$passwordHasher = new BlowfishPasswordHasher();
$qrCode = $passwordHasher->hash($qrCode);
$this->Trade->saveField('qr_code', $qrCode);
$message = array(__('The trade has been saved.'));
$general_response = array('data' => $qrCode, 'status' => 'success', 'message' => $message);
} else {
$message = array(__('The trade could not be saved. Please, try again.'));
$general_response = array('data' => null, 'status' => 'failure', 'message' => $message);
}
$this->set(array('general_response' => $general_response, '_serialize' => array('general_response')));
}
}
示例6: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
}
示例7: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher(array('hashType' => 'md5'));
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
return true;
}
示例8: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data['User']['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
}
return true;
}
示例9: beforeSave
/**
* beforeSave function
* @return bool
*/
public function beforeSave()
{
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
return true;
}
示例10: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['clave_de_acceso'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['clave_de_acceso'] = $passwordHasher->hash($this->data[$this->alias]['clave_de_acceso']);
}
return true;
}
示例11: beforeSave
public function beforeSave($options = [])
{
//パスワードのハッシュ化のため
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
return true;
}
示例12: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
$this->data[$this->alias]['dataEntrada'] = Date('c');
return true;
}
示例13: beforeSave
public function beforeSave($options = array())
{
if (!empty($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
} else {
unset($this->data[$this->alias]['password']);
}
return true;
}
示例14: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
}
if (isset($this->data[$this->alias]['avatar']) && is_array($this->data[$this->alias]['avatar'])) {
$this->__uploadAvatar($this->data[$this->alias]['avatar']);
}
return true;
}
示例15: after
public function after($event = array())
{
if (isset($event['create'])) {
$table = $event['create'];
$data = null;
switch ($table) {
case 'base_types':
$data = array(array('name' => __('Beef')), array('name' => __('Bread')), array('name' => __('Egg')), array('name' => __('Fruit')), array('name' => __('Grain')), array('name' => __('Lamb')), array('name' => __('Other')), array('name' => __('Pasta')), array('name' => __('Pork/Ham')), array('name' => __('Poultry')), array('name' => __('Seafood')), array('name' => __('Vegetable')));
break;
case 'courses':
$data = array(array('name' => __('Breakfast')), array('name' => __('Snack')), array('name' => __('Lunch')), array('name' => __('Appetizer')), array('name' => __('Side Dish')), array('name' => __('Entree')), array('name' => __('Dessert')), array('name' => __('Beverage')));
break;
case 'difficulties':
$data = array(array('name' => __('Easy')), array('name' => __('Intermediate')), array('name' => __('Difficult')), array('name' => __('Expert')));
break;
case 'ethnicities':
$data = array(array('name' => __('American')), array('name' => __('Chinese')), array('name' => __('German')), array('name' => __('Greek')), array('name' => __('Indian')), array('name' => __('Italian')), array('name' => __('Japanese')), array('name' => __('Mexican')), array('name' => __('Middle Eastern')), array('name' => __('None')), array('name' => __('Slavic')));
break;
case 'locations':
$data = array(array('name' => __('Alcohol')), array('name' => __('Bakery')), array('name' => __('Beans')), array('name' => __('Bread')), array('name' => __('Candy')), array('name' => __('Canned Fruit')), array('name' => __('Canned Meat & Fish')), array('name' => __('Canned Vegetables')), array('name' => __('Coffee, Tea & Cocoa')), array('name' => __('Condiments')), array('name' => __('Cookies')), array('name' => __('Crackers')), array('name' => __('Dairy')), array('name' => __('Deli')), array('name' => __('Drink mix')), array('name' => __('Facial Tissue')), array('name' => __('Free')), array('name' => __('Frozen Foods')), array('name' => __('HABA')), array('name' => __('Hand Soap')), array('name' => __('Hot & Cold Cereal')), array('name' => __('Household Cleaners')), array('name' => __('Juice & Cocktail')), array('name' => __('Kosher/Ethnic')), array('name' => __('Laundry Detergents')), array('name' => __('Meat')), array('name' => __('Natural & Organic')), array('name' => __('Oil/Vinegar/Dressings')), array('name' => __('Pancakes & Syrup')), array('name' => __('Paper Serving Ware')), array('name' => __('Pasta & Sauce')), array('name' => __('Peanut Butter/Jelly/Honey')), array('name' => __('Produce')), array('name' => __('Rice')), array('name' => __('Salty Snacks & Chips')), array('name' => __('Seafood')), array('name' => __('Soda pop')), array('name' => __('Soup')), array('name' => __('Spices')), array('name' => __('Toilet Paper')));
break;
case 'meal_names':
$data = array(array('name' => __('Breakfast')), array('name' => __('Lunch')), array('name' => __('Dinner')), array('name' => __('Dessert')));
break;
case 'preparation_methods':
$data = array(array('name' => __('Slow cooker')), array('name' => __('Microwave')), array('name' => __('BBQ')), array('name' => __('Canning')));
break;
case 'preparation_times':
$data = array(array('name' => __('0 Minutes')), array('name' => __('1-10 Minutes')), array('name' => __('10-30 Minutes')), array('name' => __('30-60 Minutes')), array('name' => __('60+ Minutes')));
break;
case 'price_ranges':
$data = array(array('name' => __('$0-$10')), array('name' => __('$10-$15')), array('name' => __('$15-$20')), array('name' => __('$20-$25')), array('name' => __('$25-$30')), array('name' => __('$30+')));
break;
case 'stores':
$data = array(array('name' => 'default', 'layout' => '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40'));
break;
case 'units':
$data = array(array('id' => 1, 'name' => __('Unit'), 'abbreviation' => 'ea', 'system' => 0, 'sort_order' => 0), array('id' => 2, 'name' => __('Slice'), 'abbreviation' => 'sli', 'system' => 0, 'sort_order' => 0), array('id' => 3, 'name' => __('Clove'), 'abbreviation' => 'clv', 'system' => 0, 'sort_order' => 0), array('id' => 4, 'name' => __('Pinch'), 'abbreviation' => 'pn', 'system' => 0, 'sort_order' => 0), array('id' => 5, 'name' => __('Package'), 'abbreviation' => 'pk', 'system' => 0, 'sort_order' => 0), array('id' => 6, 'name' => __('Can'), 'abbreviation' => 'cn', 'system' => 0, 'sort_order' => 0), array('id' => 7, 'name' => __('Drop'), 'abbreviation' => 'dr', 'system' => 0, 'sort_order' => 0), array('id' => 8, 'name' => __('Bunch'), 'abbreviation' => 'bn', 'system' => 0, 'sort_order' => 0), array('id' => 9, 'name' => __('Dash'), 'abbreviation' => 'ds', 'system' => 0, 'sort_order' => 0), array('id' => 10, 'name' => __('Carton'), 'abbreviation' => 'ct', 'system' => 0, 'sort_order' => 0), array('id' => 11, 'name' => __('Cup'), 'abbreviation' => 'c', 'system' => 1, 'sort_order' => 0), array('id' => 12, 'name' => __('Tablespoon'), 'abbreviation' => 'T', 'system' => 1, 'sort_order' => 0), array('id' => 13, 'name' => __('Teaspoon'), 'abbreviation' => 't', 'system' => 1, 'sort_order' => 0), array('id' => 14, 'name' => __('Pound'), 'abbreviation' => 'lb', 'system' => 1, 'sort_order' => 0), array('id' => 15, 'name' => __('Ounce'), 'abbreviation' => 'oz', 'system' => 1, 'sort_order' => 0), array('id' => 16, 'name' => __('Pint'), 'abbreviation' => 'pt', 'system' => 1, 'sort_order' => 0), array('id' => 17, 'name' => __('Quart'), 'abbreviation' => 'q', 'system' => 1, 'sort_order' => 0), array('id' => 18, 'name' => __('Gallon'), 'abbreviation' => 'gal', 'system' => 1, 'sort_order' => 0), array('id' => 19, 'name' => __('Milligram'), 'abbreviation' => 'mg', 'system' => 2, 'sort_order' => 0), array('id' => 20, 'name' => __('Centigram'), 'abbreviation' => 'cg', 'system' => 2, 'sort_order' => 0), array('id' => 21, 'name' => __('Gram'), 'abbreviation' => 'g', 'system' => 2, 'sort_order' => 0), array('id' => 22, 'name' => __('Kilogram'), 'abbreviation' => 'kg', 'system' => 2, 'sort_order' => 0), array('id' => 23, 'name' => __('Milliliter'), 'abbreviation' => 'ml', 'system' => 2, 'sort_order' => 0), array('id' => 24, 'name' => __('Centiliter'), 'abbreviation' => 'cl', 'system' => 2, 'sort_order' => 0), array('id' => 25, 'name' => __('Liter'), 'abbreviation' => 'l', 'system' => 2, 'sort_order' => 0), array('id' => 26, 'name' => __('Deciliter'), 'abbreviation' => 'dl', 'system' => 2, 'sort_order' => 0), array('id' => 27, 'name' => __('Tablespoon_m'), 'abbreviation' => 'tbsp', 'system' => 2, 'sort_order' => 0), array('id' => 28, 'name' => __('Teaspoon_m'), 'abbreviation' => 'tsp', 'system' => 2, 'sort_order' => 0));
break;
case 'users':
$passwordHasher = new BlowfishPasswordHasher();
$data = array(array('username' => 'admin', 'password' => $passwordHasher->hash('passwd'), 'name' => 'Administrator', 'access_level' => Configure::read('AuthRoles.admin'), 'email' => 'user@localhost'));
break;
case 'vendors':
$data = array(array('name' => 'Presto Fresh Grocery', 'home_url' => 'http://www.prestofreshgrocery.com/', 'add_url' => 'http://www.prestofreshgrocery.com/checkout/cart/add/uenc/a/product/'));
break;
default:
}
if ($data) {
ClassRegistry::init($table)->saveAll($data);
}
}
}