本文整理汇总了PHP中account::changePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP account::changePassword方法的具体用法?PHP account::changePassword怎么用?PHP account::changePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account
的用法示例。
在下文中一共展示了account::changePassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
if (!$account->isAuthenticated()) {
// The user is not logged in so forward them to the login page.
header("Location: login.php?origin=" . urlencode('account.php'));
}
if ($common->postBack()) {
// Check that the user supplied a password matching the one currently stored in administrators.xml.
$authenticated = $account->authenticate($_SESSION['login'], $_POST['password'], FALSE, FALSE);
if (!$authenticated) {
$passwordIncorrect = TRUE;
}
if ($_POST['password1'] != $_POST['password2']) {
$didNotMatch = TRUE;
}
if ($authenticated && $_POST['password1'] == $_POST['password2']) {
// Change the password stored in administrators.xml related to this users login.
$account->changePassword($_SESSION['login'], $_POST['password1']);
// Since the password has changed we will log the user out to clear older session variables.
$account->logout();
}
}
require_once 'includes/header.inc.php';
/////////////////////
// BEGIN HTML BODY //
if ($_SESSION['firstLogin'] && !$common->postBack()) {
?>
<div id="first-login-modal" class="modal fade in" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<strong>First time login detected.</strong><br />
You must change the default password before continuing.
示例2: header
$validToken = TRUE;
// Check the length of the password.
$tooShort = TRUE;
if (isset($_POST['password1']) && strlen($_POST['password1']) >= $settings::sec_length) {
$tooShort = FALSE;
}
// Check that the supplied new passwords match.
$notMatching = TRUE;
if ($_POST['password1'] == $_POST['password2']) {
$notMatching = FALSE;
}
// If everything associated with passwords is validated change the password.
if (!$tooShort && !$notMatching) {
// Change the password stored in administrators.xml related to this users login.
$account->setToken($login);
$account->changePassword($login, password_hash($_POST['password1'], PASSWORD_DEFAULT));
header("Location: login.php");
}
}
}
/////////////////////
// BEGIN HTML BODY //
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="assets/css/reset.css" />
示例3:
// Check the length of the password.
$tooShort = TRUE;
if (isset($_POST['password1']) && strlen($_POST['password1']) >= $settings::sec_length) {
$tooShort = FALSE;
}
// Check that the supplied new passwords match.
$notMatching = TRUE;
if ($_POST['password1'] == $_POST['password2']) {
$notMatching = FALSE;
}
// Check that the supplied current password matches that which is stored.
$authenticated = $account->authenticate($_SESSION['login'], $_POST['password'], FALSE, FALSE);
// If everything associated with passwords is validated change the password.
if (!$tooShort && !$notMatching && $authenticated) {
// Change the password stored in administrators.xml related to this users login.
$account->changePassword($_SESSION['login'], password_hash($_POST['password1'], PASSWORD_DEFAULT));
$passwordChanged = TRUE;
}
}
// If validation passed make the requested changes to the administrator account data.
if ($nameSupplied && $validEmail) {
$account->changeName($_SESSION['login'], $_POST['name']);
$account->changeEmail($_SESSION['login'], $_POST['email']);
$updated = TRUE;
}
// Since the password has changed we will log the user out to clear older session variables.
if ($passwordChanged) {
$account->logout();
}
}
require_once 'includes/header.inc.php';