当前位置: 首页>>代码示例>>PHP>>正文


PHP User::encryptPassword方法代码示例

本文整理汇总了PHP中User::encryptPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::encryptPassword方法的具体用法?PHP User::encryptPassword怎么用?PHP User::encryptPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User::encryptPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createNew

 function createNew()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('username', 'Username', 'required|is_unique[user.login]');
     $this->form_validation->set_rules('password', 'Password', 'required');
     $this->form_validation->set_rules('first', 'First', "required");
     $this->form_validation->set_rules('last', 'last', "required");
     $this->form_validation->set_rules('email', 'Email', "required|is_unique[user.email]");
     if ($this->form_validation->run() == FALSE) {
         $this->load->view('account/newForm');
     } else {
         include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
         $securimage = new Securimage();
         if ($securimage->check($_POST['captcha_code']) == false) {
             echo "The security code entered was incorrect.<br /><br />";
             echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
             exit;
         }
         $user = new User();
         $user->login = $this->input->post('username');
         $user->first = $this->input->post('first');
         $user->last = $this->input->post('last');
         $clearPassword = $this->input->post('password');
         $user->encryptPassword($clearPassword);
         $user->email = $this->input->post('email');
         $this->load->model('user_model');
         $error = $this->user_model->insert($user);
         $this->load->view('account/loginForm');
     }
 }
开发者ID:ajitpawar,项目名称:connect4,代码行数:30,代码来源:account.php

示例2: actionRegister

 public function actionRegister()
 {
     $formModel = new Registration();
     //$this->performAjaxValidation($formModel);
     if (isset($_POST['Registration'])) {
         $formModel->email = $_POST['Registration']['email'];
         $formModel->username = $_POST['Registration']['username'];
         $formModel->password = $_POST['Registration']['password'];
         $formModel->password_repeat = $_POST['Registration']['password_repeat'];
         $formModel->verification_code = $_POST['Registration']['verification_code'];
         if ($formModel->validate()) {
             $model = new User();
             if ($model->insert(CassandraUtil::uuid1(), array('email' => $_POST['Registration']['email'], 'username' => $_POST['Registration']['username'], 'password' => User::encryptPassword($_POST['Registration']['password']), 'active' => false, 'blocked' => false)) === true) {
                 echo 'Model email ' . $formModel->email . ' && username ' . $formModel->username;
                 if (!User::sendRegisterVerification($formModel->email, $formModel->username)) {
                     echo 'failed';
                 } else {
                     echo 'done';
                 }
                 die;
                 //$this->redirect(array('user/profile'));
             }
         }
     }
     $this->render('register', array('model' => $formModel));
 }
开发者ID:redlaw,项目名称:lintinzone,代码行数:26,代码来源:RegistrationController.php

示例3: beforeSave

 /**
  * @param User $model
  */
 public function beforeSave(&$model)
 {
     if ($model->varPassword) {
         $model->varPassword = $model->encryptPassword($model->varPassword);
     } else {
         unset($model->varPassword);
     }
 }
开发者ID:GatuZa,项目名称:test-app,代码行数:11,代码来源:UserController.php

示例4: resolvePasswordParameter

 protected function resolvePasswordParameter(&$params)
 {
     // We have to encrypt password
     if (isset($params['data']['password']) && $params['data']['password'] != '') {
         $params['data']['hash'] = User::encryptPassword($params['data']['password']);
     }
     unset($params['data']['password']);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:8,代码来源:UserApiController.php

示例5: loginMail

function loginMail()
{
    $errMsg = '';
    if (!isset($_GET['email'])) {
        $errMsg .= 'email';
    }
    if (!isset($_GET['password'])) {
        if (strlen($errMsg) > 0) {
            $errMsg .= ', ';
        }
        $errMsg .= 'password';
    }
    if (strlen($errMsg) > 0) {
        // At least one of the fields is not set, so return an error
        sendMessage(ERR, 'The following required parameters are not set: [' . $errMsg . ']');
        return;
    }
    $email = $_GET['email'];
    $password = $_GET['password'];
    // Check if user exists
    $db = acquireDatabase();
    $loader = new User($db);
    try {
        $res = $loader->loadWhere('email=?', [$email]);
        if (sizeof($res) > 0) {
            $user = $res[0];
            // Check if password is correct
            $validPassword = $user->getPassword();
            $password = User::encryptPassword($password);
            if ($validPassword == $password) {
                // Login successful -> return session id
                session_start();
                $_SESSION['uid'] = $user->getId();
                $_SESSION['email'] = $user->getEmail();
                if ($user->getState() == 'FILL_DATA') {
                    sendMessage(WARN, 'Login successful. Please complete your registration.');
                } else {
                    $_SESSION['name'] = $user->getName();
                    sendMessage(OK, 'Login successful.');
                }
            } else {
                sendMessage(ERR, 'Password invalid.');
            }
        } else {
            // User doesn't exist
            sendMessage(ERR, 'User invalid.');
        }
    } catch (DbException $e) {
        sendMessage(ERR, $e->getMessage());
    }
    $db->close();
}
开发者ID:Tucaen,项目名称:Karlsfeld-Volleyball-App,代码行数:52,代码来源:login.php

示例6: authenticate

 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Customer::model()->findByAttributes(array('email' => $this->username, 'status' => 1));
     if (is_null($user)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password != User::encryptPassword($this->password, $user->salt)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:18,代码来源:CustomerIdentity.php

示例7: authenticate

 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = User::model()->findByAttributes(array('username' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== User::encryptPassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:jayrulez,项目名称:yiisns,代码行数:19,代码来源:UserIdentity.php

示例8: signup

 /**
  * 创建新账号
  */
 public function signup()
 {
     $user = new User();
     $user->email = $this->email;
     $user->name = $this->username;
     $user->password = $this->password;
     $user->state = param('user_required_admin_verfiy') || param('用户注册是否需要管理员审核') ? USER_STATE_UNVERIFY : USER_STATE_ENABLED;
     $user->encryptPassword();
     $result = $user->save();
     if ($result) {
         $this->afterSignup($user);
         return true;
     } else {
         return false;
     }
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:19,代码来源:LoginForm.php

示例9: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     Yii::app()->theme = '';
     $model = new User('admin');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->encryptPassword($model->password);
         $model->rePassword = $model->password;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $model->password = '';
     $model->rePassword = '';
     $this->render('create', array('model' => $model));
 }
开发者ID:qkongvan,项目名称:k6-thuc-pham,代码行数:22,代码来源:AdminController.php

示例10: resolveValueForImport

 /**
  * @param mixed $value
  * @param string $columnName
  * @param array $columnMappingData
  * @param ImportSanitizeResultsUtil $importSanitizeResultsUtil
  * @return array|void
  */
 public function resolveValueForImport($value, $columnName, $columnMappingData, ImportSanitizeResultsUtil $importSanitizeResultsUtil)
 {
     $attributeNames = $this->getRealModelAttributeNames();
     assert('count($attributeNames) == 1');
     assert('$attributeNames[0] == "hash"');
     assert('is_string($columnName)');
     assert('is_array($columnMappingData)');
     $modelClassName = $this->getModelClassName();
     $value = ImportSanitizerUtil::sanitizeValueBySanitizerTypes(static::getSanitizerUtilTypesInProcessingOrder(), $modelClassName, 'hash', $value, $columnName, $columnMappingData, $importSanitizeResultsUtil);
     if ($value == null) {
         $mappingRuleFormClassName = 'PasswordDefaultValueModelAttributeMappingRuleForm';
         $mappingRuleData = $columnMappingData['mappingRulesData'][$mappingRuleFormClassName];
         assert('$mappingRuleData != null');
         if (isset($mappingRuleData['defaultValue'])) {
             $value = $mappingRuleData['defaultValue'];
         }
     }
     return array('hash' => User::encryptPassword($value));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:PasswordAttributeImportRules.php

示例11: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //create is name of scenario
     $model = new User('scenarioCreate');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->encryptPassword();
         $transaction = Yii::app()->db->beginTransaction();
         try {
             if ($model->save()) {
                 $successful = true;
                 if ($model->assignRolesToUser($model->id) == $successful) {
                     $transaction->commit();
                     /*if (!empty($_POST['yt1'])) 
                       {
                           Yii::app()->user->setFlash('activityGuarantee-created', "¡La actividad <b><i>&quot;$model->description&quot;</i></b> fue creada exitosamente!");
                           $model=new ActivityGuarantee;
                       }
                       else*/
                     $this->redirect(array('view', 'id' => $model->id));
                 } else {
                     $transaction->rollBack();
                 }
             }
         } catch (Exception $e) {
             $transaction->rollBack();
         }
     }
     if (Role::model()->count('active = 1') > 0) {
         $this->render('create', array('model' => $model));
     } else {
         if (Role::model()->count('active = 0') > 0) {
             throw new CHttpException('', 'Primero debes ' . CHtml::link('crear rol', array('role/create')) . ' o ' . CHtml::link('activar ', array('role/admin')) . 'algún rol' . '.');
         } else {
             throw new CHttpException('', 'Primero debes ' . CHtml::link('crear rol', array('role/create')) . '.');
         }
     }
 }
开发者ID:rodespsan,项目名称:LMEC,代码行数:44,代码来源:UserController.php

示例12: configure

 public function configure()
 {
     try {
         $val = Loader::helper('validation/form');
         $val->setData($this->post());
         $val->addRequired("SITE", t("Please specify your site's name"));
         $val->addRequiredEmail("uEmail", t('Please specify a valid email address'));
         $val->addRequired("DB_DATABASE", t('You must specify a valid database name'));
         $val->addRequired("DB_SERVER", t('You must specify a valid database server'));
         $e = Loader::helper('/validation/error');
         if (is_object($this->fileWriteErrors)) {
             $e = $this->fileWriteErrors;
         }
         if (!function_exists('mysql_connect')) {
             $e->add($this->getDBErrorMsg());
         } else {
             // attempt to connect to the database
             $db = Loader::db($_POST['DB_SERVER'], $_POST['DB_USERNAME'], $_POST['DB_PASSWORD'], $_POST['DB_DATABASE'], true);
             if ($_POST['DB_SERVER'] && $_POST['DB_DATABASE']) {
                 if (!$db) {
                     $e->add(t('Unable to connect to database.'));
                 } else {
                     $num = $db->GetCol("show tables");
                     if (count($num) > 0) {
                         $e->add(t('There are already %s tables in this database. Concrete must be installed in an empty database.', count($num)));
                     }
                 }
             }
         }
         if ($val->test() && !$e->has()) {
             if (!is_dir($this->installData['DIR_FILES_UPLOADED_THUMBNAILS'])) {
                 mkdir($this->installData['DIR_FILES_UPLOADED_THUMBNAILS']);
             }
             if (!is_dir($this->installData['DIR_FILES_INCOMING'])) {
                 mkdir($this->installData['DIR_FILES_INCOMING']);
             }
             if (!is_dir($this->installData['DIR_FILES_TRASH'])) {
                 mkdir($this->installData['DIR_FILES_TRASH']);
             }
             if (!is_dir($this->installData['DIR_FILES_CACHE'])) {
                 mkdir($this->installData['DIR_FILES_CACHE']);
             }
             if (!is_dir($this->installData['DIR_FILES_CACHE_DB'])) {
                 mkdir($this->installData['DIR_FILES_CACHE_DB']);
             }
             if (!is_dir($this->installData['DIR_FILES_AVATARS'])) {
                 mkdir($this->installData['DIR_FILES_AVATARS']);
             }
             if (isset($_POST['uPasswordForce'])) {
                 $this->installData['uPassword'] = $_POST['uPasswordForce'];
             }
             if (isset($_POST['packages'])) {
                 $this->installData['packages'] = $_POST['packages'];
             }
             $this->installDB();
             $vh = Loader::helper('validation/identifier');
             // copy the files
             $fh = Loader::helper('file');
             if ($_POST['INSTALL_SAMPLE_CONTENT']) {
                 $fh->copyAll($this->installData['DIR_BASE_CORE'] . '/config/install/files', DIR_FILES_UPLOADED);
             }
             // insert admin user into the user table
             $salt = defined('MANUAL_PASSWORD_SALT') ? MANUAL_PASSWORD_SALT : $vh->getString(64);
             if (!isset($this->installData['uPassword'])) {
                 $uPassword = rand(100000, 999999);
             } else {
                 $uPassword = $this->installData['uPassword'];
             }
             $uEmail = $_POST['uEmail'];
             $uPasswordEncrypted = User::encryptPassword($uPassword, $salt);
             UserInfo::addSuperUser($uPasswordEncrypted, $uEmail);
             if (defined('PERMISSIONS_MODEL') && PERMISSIONS_MODEL != 'simple') {
                 $setPermissionsModel = PERMISSIONS_MODEL;
             }
             if (file_exists($this->installData['DIR_CONFIG_SITE'])) {
                 $this->fp = @fopen($this->installData['DIR_CONFIG_SITE'] . '/site.php', 'w+');
                 if ($this->fp) {
                     Cache::flush();
                     if (is_array($this->installData['packages'])) {
                         foreach ($this->installData['packages'] as $pkgHandle) {
                             $p = Loader::package($pkgHandle);
                             $p->install();
                         }
                     }
                     // write the config file
                     $configuration = "<?php\n";
                     $configuration .= "define('DB_SERVER', '" . addslashes($_POST['DB_SERVER']) . "');\n";
                     $configuration .= "define('DB_USERNAME', '" . addslashes($_POST['DB_USERNAME']) . "');\n";
                     $configuration .= "define('DB_PASSWORD', '" . addslashes($_POST['DB_PASSWORD']) . "');\n";
                     $configuration .= "define('DB_DATABASE', '" . addslashes($_POST['DB_DATABASE']) . "');\n";
                     $configuration .= "define('BASE_URL', '" . $this->installData['BASE_URL'] . "');\n";
                     $configuration .= "define('DIR_REL', '" . $this->installData['DIR_REL'] . "');\n";
                     if (isset($setPermissionsModel)) {
                         $configuration .= "define('PERMISSIONS_MODEL', '" . addslashes($setPermissionsModel) . "');\n";
                     }
                     $configuration .= "define('PASSWORD_SALT', '{$salt}');\n";
                     if (is_array($_POST['SITE_CONFIG'])) {
                         foreach ($_POST['SITE_CONFIG'] as $key => $value) {
                             $configuration .= "define('" . $key . "', '" . $value . "');\n";
                         }
//.........这里部分代码省略.........
开发者ID:VonUniGE,项目名称:concrete5-1,代码行数:101,代码来源:install.php

示例13: __construct

 public function __construct()
 {
     $args = func_get_args();
     if (isset($args[1])) {
         // first, we check to see if the username and password match the admin username and password
         // $username = uName normally, but if not it's email address
         $username = $args[0];
         $password = $args[1];
         if (!$args[2]) {
             $_SESSION['uGroups'] = false;
         }
         $password = User::encryptPassword($password, PASSWORD_SALT);
         $v = array($username, $password);
         if (defined('USER_REGISTRATION_WITH_EMAIL_ADDRESS') && USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
             $q = "select uID, uName, uIsActive, uIsValidated, uTimezone, uDefaultLanguage from Users where uEmail = ? and uPassword = ?";
         } else {
             $q = "select uID, uName, uIsActive, uIsValidated, uTimezone, uDefaultLanguage from Users where uName = ? and uPassword = ?";
         }
         $db = Loader::db();
         $r = $db->query($q, $v);
         if ($r) {
             $row = $r->fetchRow();
             if ($row['uID'] && $row['uIsValidated'] === '0' && defined('USER_VALIDATE_EMAIL_REQUIRED') && USER_VALIDATE_EMAIL_REQUIRED == TRUE) {
                 $this->loadError(USER_NON_VALIDATED);
             } else {
                 if ($row['uID'] && $row['uIsActive']) {
                     $this->uID = $row['uID'];
                     $this->uName = $row['uName'];
                     $this->uIsActive = $row['uIsActive'];
                     $this->uTimezone = $row['uTimezone'];
                     $this->uDefaultLanguage = $row['uDefaultLanguage'];
                     $this->uGroups = $this->_getUserGroups($args[2]);
                     if ($row['uID'] == USER_SUPER_ID) {
                         $this->superUser = true;
                     } else {
                         $this->superUser = false;
                     }
                     $this->recordLogin();
                     if (!$args[2]) {
                         $_SESSION['uID'] = $row['uID'];
                         $_SESSION['uName'] = $row['uName'];
                         $_SESSION['superUser'] = $this->superUser;
                         $_SESSION['uBlockTypesSet'] = false;
                         $_SESSION['uGroups'] = $this->uGroups;
                         $_SESSION['uTimezone'] = $this->uTimezone;
                         $_SESSION['uDefaultLanguage'] = $this->uDefaultLanguage;
                     }
                 } else {
                     if ($row['uID'] && !$row['uIsActive']) {
                         $this->loadError(USER_INACTIVE);
                     } else {
                         $this->loadError(USER_INVALID);
                     }
                 }
             }
             $r->free();
         } else {
             $this->loadError(USER_INVALID);
         }
     } else {
         // then we just get session info
         if (isset($_SESSION['uID'])) {
             $this->uID = $_SESSION['uID'];
             $this->uName = $_SESSION['uName'];
             $this->uTimezone = $_SESSION['uTimezone'];
             $this->uDefaultLanguage = $_SESSION['uDefaultLanguage'];
             $this->superUser = $_SESSION['uID'] == USER_SUPER_ID ? true : false;
         } else {
             $this->uID = null;
             $this->uName = null;
             $this->superUser = false;
             $this->uDefaultLanguage = null;
             $this->uTimezone = null;
         }
         $this->uGroups = $this->_getUserGroups();
         if (!isset($args[2])) {
             $_SESSION['uGroups'] = $this->uGroups;
         }
     }
     return $this;
 }
开发者ID:VonUniGE,项目名称:concrete5-1,代码行数:81,代码来源:user.php

示例14: resetUserPassword

		function resetUserPassword() {
			// resets user's password, and returns the value of the reset password
			$db = Loader::db();
			if ($this->uID > 0) {
				$newPassword = '';
				$salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
				for ($i = 0; $i < 7; $i++) {
					$newPassword .= substr($salt, rand() %strlen($salt), 1);
				}
				$v = array(User::encryptPassword($newPassword), $this->uID);
				$q = "update Users set uPassword = ? where uID = ?";
				$r = $db->query($q, $v);
				if ($r) {
					return $newPassword;
				}
			}
		}
开发者ID:rii-J,项目名称:concrete5-de,代码行数:17,代码来源:userinfo.php

示例15: elseif

 }
 if (strlen($password) < 5) {
     $error = true;
     $oUser->addStatusMessage(_('password is too short'), 'warning');
 } elseif ($password != $confirmation) {
     $error = true;
     $oUser->addStatusMessage(_('password confirmation does not match'), 'warning');
 }
 $allreadyExists = \Ease\Shared::db()->queryToValue('SELECT id FROM user WHERE login=\'' . $oPage->EaseAddSlashes($login) . '\'');
 if ($allreadyExists) {
     $error = true;
     $oUser->addStatusMessage(sprintf(_('Given Username %s already exists'), $login), 'warning');
 }
 if ($error == false) {
     $newOUser = new User();
     $customerData = ['firstname' => $firstname, 'lastname' => $lastname, 'email' => $email_address, 'password' => $newOUser->encryptPassword($password), 'login' => $login];
     $customerID = $newOUser->insertToSQL($customerData);
     if ($customerID) {
         $newOUser->setMyKey($customerID);
         $oUser->addStatusMessage(_('Account Was Created'), 'success');
         $newOUser->loginSuccess();
         $email = $oPage->addItem(new \Ease\Mail($newOUser->getDataValue('email'), _('New LinkQuick account')));
         $email->setMailHeaders(['From' => EMAIL_FROM]);
         $email->addItem(new \Ease\Html\Div(_("Welcome to LinkQuick") . "\n"));
         $email->addItem(new \Ease\Html\Div(_('Login') . ': ' . $newOUser->getUserLogin() . "\n"));
         $email->addItem(new \Ease\Html\Div(_('Password') . ': ' . $password . "\n"));
         $email->send();
         \Ease\Shared::user($newOUser);
         //Assign newly created user as default
         $oPage->redirect('index.php');
         exit;
开发者ID:VitexSoftware,项目名称:LinkQuick,代码行数:31,代码来源:createaccount.php


注:本文中的User::encryptPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。