本文整理汇总了PHP中Password::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::generate方法的具体用法?PHP Password::generate怎么用?PHP Password::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Password
的用法示例。
在下文中一共展示了Password::generate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->confirmed_at = time();
if ($this->password == null) {
$this->password = Password::generate(8);
}
$this->trigger(self::USER_CREATE_INIT);
if ($this->save()) {
$this->trigger(self::USER_CREATE_DONE);
$this->mailer->sendWelcomeMessage($this);
\Yii::getLogger()->log('User has been created', Logger::LEVEL_INFO);
return true;
}
\Yii::getLogger()->log('An error occurred while creating user account', Logger::LEVEL_ERROR);
return false;
}
示例2: Password
$user_register = false;
$userId = null;
$user = null;
$promoSale = 0;
$registerSale = 0;
$email = null;
if (!empty($_POST['cart_email']) && !$users->is_auth_shopuser() && !empty($_POST['cart_password'])) {
$users->setEmail($_POST['cart_email']);
$users->setName($_POST['cart_name']);
$users->setPhone1($_POST['cart_phone']);
$users->setAddress($_POST['cart_address']);
if (!empty($_POST['cart_password'])) {
$users->setPassword($_POST['cart_password']);
} else {
$password = new Password();
$users->setPassword($password->generate());
}
if (!$users->get_user_by_email($_POST['cart_email'])) {
$user = $users->register();
$user_register = true;
} else {
$smarty->assign('error_register_message', 'Пользователь с тами email уже зарегистрирован');
$error_register = true;
}
//если ввел пароль, то отпавляем письмо о регистрации пользователя
if (!empty($_POST['cart_password']) && $user_register) {
$mail_template = $db->get_single("SELECT template FROM fw_mails_templates WHERE mail_key='REGISTOR_MAIL'");
$message_body = $smarty->fetch('/modules/cabinet/front/templates/registration_mail.txt');
$message_body = $mail_template['template'];
$message_body = str_replace("{site_url}", BASE_URL, $message_body);
$message_body = str_replace("{login}", $user['login'], $message_body);
示例3: pwverify
public function pwverify()
{
$this->breadcrumb->add('Neues Passwort generieren');
$this->header();
if (Me::get()->loggedIn()) {
CmsPage::error('Sie sind bereits angemeldet!');
} else {
$uid = Request::get(1, VAR_INT);
$hash = Request::get(2, VAR_ALNUM);
$user = UserUtils::getById($uid);
if ($user !== null && $user->isActive() && strcmp($hash, $user->getVerificationCode()) == 0) {
$pw = Password::generate();
$pwh = Hash::generate($pw);
$db = Database::getObject();
$db->query("UPDATE <p>user SET pw = <pwh>, verification = '' WHERE id = <uid:int>", compact("uid", "pwh"));
if ($db->affectedRows() == 1) {
$db = Database::getObject();
$db->query("UPDATE <p>user SET verification = <pwh> WHERE id = <uid:int> AND active = 1", compact("pwh", "uid"));
$tpl = Response::getObject()->getTemplate('Cms/mails/pwremind_newpw');
$tpl->assign('pw', $pw, false);
$tpl->assign('name', UserUtils::getSalutation($user->getGender(), $user->getForeName(), $user->getSurName()), false);
CmsTools::sendMail($user->getEmail(), Config::get('general.title') . ': Ihr neues Passwort', $tpl->parse());
CmsPage::ok("Ihr neues Passwort wurden Ihnen per E-Mail zugeschicht.", URI::build("cms/user/login"));
} else {
CmsPage::error("Es ist ein Fehler bei der Generierung eines neuen Passworts aufgetreten. Bitte wernden Sie sich an den Systemadministrator.", URI::build("cms/contact"));
}
} else {
CmsPage::error("Die angegebenen Daten sind nicht mehr gültig.", URI::build("cms/user/pwremind"));
}
}
$this->footer();
}
示例4: Password
//header ("Location: /");
die;
}
if (isset($_POST['submit_user_register'])) {
$registration_success = true;
//$pwd = new Password();
//$password=$pwd->generate();
$login = String::secure_user_input($_POST['useremail']);
$name = String::secure_user_input(iconv('utf-8', 'windows-1251', $_POST['username']));
$password = String::secure_user_input(iconv('utf-8', 'windows-1251', $_POST['pass']));
$phone = String::secure_user_input($_POST['phone']);
$address = String::secure_user_input(iconv('utf-8', 'windows-1251', $_POST['address']));
//если юзер не ввел пароль
if (empty($password)) {
$pwd = new Password();
$password = $pwd->generate();
}
if (!preg_match("/^([0-9A-z\\._-]+)@([0-9A-z\\._-]+)\\.([A-z]+)\$/", $login)) {
$registration_success = false;
$smarty->assign("error_message", "Неправильный формат e-mail адреса");
echo "error1";
exit;
} else {
$result = $db->get_all("SELECT login FROM fw_users WHERE login='{$login}'");
if (count($result) > 0) {
$registration_success = false;
$smarty->assign("error_message", "Пользователь с таким почтовым адресом уже существует.");
echo "error2";
exit;
}
}