本文整理匯總了PHP中Generic::validatePassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generic::validatePassword方法的具體用法?PHP Generic::validatePassword怎麽用?PHP Generic::validatePassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Generic
的用法示例。
在下文中一共展示了Generic::validatePassword方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
private function validate()
{
if (empty($this->settings['CurrentPass'])) {
$this->error = '<div class="alert alert-error">' . _('You must enter the current password to make changes.') . '</div>';
return false;
}
$params = array(':username' => $this->username);
$sql = "SELECT `password` FROM `accounts` WHERE {$this->username_type} = :username;";
$stmt = parent::query($sql, $params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (!parent::validatePassword($this->settings['CurrentPass'], $row['password'])) {
$this->error = '<div class="alert alert-error">' . _('You entered the wrong current password.') . '</div>';
return false;
}
if (empty($this->settings['name'])) {
$this->error .= '<div class="alert alert-error">' . _('You must enter a name.') . '</div>';
}
if (!parent::isEmail($this->settings['email'])) {
$this->error .= '<div class="alert alert-error">' . _('You have entered an invalid e-mail address, try again.') . '</div>';
}
if (!empty($this->settings['password'])) {
if ($this->settings['password'] != $this->settings['confirm']) {
$this->error .= '<div class="alert alert-error">' . _('Your passwords did not match.') . '</div>';
}
if (strlen($this->settings['password']) < 5) {
$this->error = '<div class="alert alert-error">' . _('Your password must be at least 5 characters.') . '</div>';
}
}
// Checkbox handling
$sql = "SELECT * FROM `login_profile_fields`;";
$stmt = parent::query($sql);
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = 'p-' . $row['id'];
if ($row['type'] == 'checkbox') {
$this->settings[$name] = !empty($this->settings[$name]) ? 1 : 0;
}
}
}
示例2: validate
private function validate()
{
//If demo, check that user being edited isn't any demo user accounts
if ($this->is_demo()) {
if ($this->settings['username'] == 'admin' || $this->settings['username'] == 'special' || $this->settings['username'] == 'user') {
$this->error = '<div class="alert alert-danger">You cannot edit this user because it is a demo user. Please create a new user to test out this functionality.</div>';
return false;
}
}
if (empty($this->settings['CurrentPass'])) {
$this->error = '<div class="alert alert-danger">' . _('You must enter the current password to make changes.') . '</div>';
return false;
}
$params = array(':username' => $this->username);
$sql = "SELECT `password` FROM `login_users` WHERE {$this->username_type} = :username;";
$stmt = parent::query($sql, $params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (!parent::validatePassword($this->settings['CurrentPass'], $row['password'])) {
$this->error = '<div class="alert alert-danger">' . _('You entered the wrong current password.') . '</div>';
return false;
}
if (empty($this->settings['name'])) {
$this->error .= '<div class="alert alert-danger">' . _('You must enter a name.') . '</div>';
}
if (!parent::isEmail($this->settings['email'])) {
$this->error .= '<div class="alert alert-danger">' . _('You have entered an invalid e-mail address, try again.') . '</div>';
}
if (!empty($this->settings['password'])) {
if ($this->settings['password'] != $this->settings['confirm']) {
$this->error .= '<div class="alert alert-danger">' . _('Your passwords did not match.') . '</div>';
}
if (strlen($this->settings['password']) < 5) {
$this->error = '<div class="alert alert-danger">' . _('Your password must be at least 5 characters.') . '</div>';
}
}
// Checkbox handling
$sql = "SELECT * FROM `login_profile_fields`;";
$stmt = parent::query($sql);
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = 'p-' . $row['id'];
if ($row['type'] == 'checkbox') {
$this->settings[$name] = !empty($this->settings[$name]) ? 1 : 0;
}
}
}