本文整理汇总了PHP中ilObjUser::resetPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjUser::resetPassword方法的具体用法?PHP ilObjUser::resetPassword怎么用?PHP ilObjUser::resetPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjUser
的用法示例。
在下文中一共展示了ilObjUser::resetPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateSetLookupDelete
/**
* Creates a user, sets preferences, lookups data, changes password,
* accept user agreement, delete user
*/
public function testCreateSetLookupDelete()
{
include_once "./Services/User/classes/class.ilObjUser.php";
// delete all aatestuser from previous runs
while (($i = ilObjUser::_lookupId("aatestuser")) > 0) {
$user = new ilObjUser($i);
$user->delete();
}
$user = new ilObjUser();
// creation
$d = array("login" => "aatestuser", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "m", "firstname" => "Max", "lastname" => "Mutzke", "email" => "de@de.de", "client_ip" => "1.2.3.4", "ext_account" => "ext_mutzke");
$user->assignData($d);
$user->create();
$user->saveAsNew();
$user->setLanguage("no");
$user->writePrefs();
$id = $user->getId();
$value .= $user->getFirstname() . "-";
// update
$user->setFirstname("Maxi");
$user->update();
$value .= $user->getFirstname() . "-";
// other update methods
$user->refreshLogin();
// lookups
$value .= ilObjUser::_lookupEmail($id) . "-";
$value .= ilObjUser::_lookupGender($id) . "-";
$value .= ilObjUser::_lookupClientIP($id) . "-";
$n = ilObjUser::_lookupName($id);
$value .= $n["lastname"] . "-";
ilObjUser::_lookupFields($id);
$value .= ilObjUser::_lookupLogin($id) . "-";
$value .= ilObjUser::_lookupExternalAccount($id) . "-";
$value .= ilObjUser::_lookupId("aatestuser") . "-";
ilObjUser::_lookupLastLogin($id);
$value .= ilObjUser::_lookupLanguage($id) . "-";
ilObjUser::_readUsersProfileData(array($id));
if (ilObjUser::_loginExists("aatestuser")) {
$value .= "le-";
}
// password methods
if (ilObjUser::_checkPassword($id, "password")) {
$value .= "pw1-";
}
$user->replacePassword(md5("password2"));
if (ilObjUser::_checkPassword($id, "password2")) {
$value .= "pw2-";
}
$user->updatePassword("password2", "password3", "password3");
if (ilObjUser::_checkPassword($id, "password3")) {
$value .= "pw3-";
}
$user->resetPassword("password4", "password4");
if (ilObjUser::_checkPassword($id, "password4")) {
$value .= "pw4-";
}
// preferences...
$user->writePref("testpref", "pref1");
$value .= ilObjUser::_lookupPref($id, "testpref") . "-";
$user->deletePref("testpref");
if (ilObjUser::_lookupPref($id, "testpref") == "") {
$value .= "pref2" . "-";
}
// user agreement acceptance
if (!ilObjUser::_hasAcceptedAgreement("aatestuser")) {
$value .= "agr1-";
}
$user->writeAccepted();
if (ilObjUser::_hasAcceptedAgreement("aatestuser")) {
$value .= "agr2-";
}
// activation
$user->setActive(false);
if (!ilObjUser::getStoredActive($id)) {
}
$value .= "act1-";
$user->setActive(true);
if (ilObjUser::getStoredActive($id)) {
}
$value .= "act2-";
ilObjUser::_toggleActiveStatusOfUsers(array($id), false);
if (!ilObjUser::getStoredActive($id)) {
}
$value .= "act3-";
// deletion
$user->delete();
$this->assertEquals("Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-{$id}-no-le-" . "pw1-pw2-pw3-pw4-pref1-pref2-agr1-agr2-act1-act2-act3-", $value);
}
示例2: verifyPassword
/**
* @param ilObjUser $user
* @param string $raw
* @return bool
*/
public function verifyPassword(ilObjUser $user, $raw)
{
$encoder = $this->getEncoderFactory()->getEncoderByName($user->getPasswordEncodingType(), true);
if ($this->getEncoderName() != $encoder->getName()) {
if ($encoder->isPasswordValid($user->getPasswd(), $raw, $user->getPasswordSalt())) {
$user->resetPassword($raw, $raw);
return true;
}
return false;
} else {
return $encoder->isPasswordValid($user->getPasswd(), $raw, $user->getPasswordSalt());
}
}
示例3: submitAssignPasswordForm
/** Reads the submitted data from the password assistance form.
*
* The following form fields are read as HTTP POST parameters:
* key
* username
* password1
* password2
*
* The key is used to retrieve the password assistance session.
* If the key is missing, or if the password assistance session has expired, the
* password assistance form will be shown instead of this form.
*
* If the password assistance session is valid, and if the username matches the
* username, for which the password assistance has been requested, and if the
* new password is valid, ILIAS assigns the password to the user.
*
* Note: To prevent replay attacks, the session is deleted when the
* password has been assigned successfully.
*/
function submitAssignPasswordForm()
{
global $tpl, $ilias, $lng, $rbacadmin, $rbacreview;
require_once "include/inc.pwassist_session_handler.php";
// Retrieve form data
$pwassist_id = ilUtil::stripSlashes($_POST["key"]);
$username = ilUtil::stripSlashes($_POST["username"]);
$password1 = ilUtil::stripSlashes($_POST["password1"]);
$password2 = ilUtil::stripSlashes($_POST["password2"]);
// Retrieve the session
$pwassist_session = db_pwassist_session_read($pwassist_id);
if (count($pwassist_session) == 0 || $pwassist_session["expires"] < time()) {
$this->showAssistanceForm($lng->txt("pwassist_session_expired"));
} else {
$is_successful = true;
$message = "";
$userObj = new ilObjUser($pwassist_session["user_id"]);
// Validate the entries of the user
// ----------------------------------
// check if the user still exists
if ($userObj == null) {
$message = $lng->txt("user_does_not_exist");
$is_successful = false;
}
// check if the username entered by the user matches the
// one of the user object.
if ($is_successful && strcasecmp($userObj->getLogin(), $username) != 0) {
$message = $lng->txt("pwassist_login_not_match");
$is_successful = false;
}
// check if the user entered the password correctly into the
// two entry fields.
if ($is_successful && $password1 != $password2) {
$message = $lng->txt("passwd_not_match");
$is_successful = false;
}
// validate the password
if ($is_successful && !ilUtil::isPassword($password1)) {
$message = $lng->txt("passwd_invalid");
$is_successful = false;
}
// End of validation
// If the validation was successful, we change the password of the
// user.
// ------------------
if ($is_successful) {
$is_successful = $userObj->resetPassword($password1, $password2);
if (!$is_successful) {
$message = $lng->txt("passwd_invalid");
}
}
// If we are successful so far, we update the user object.
// ------------------
if ($is_successful) {
$is_successfull = $userObj->update();
if (!$is_successful) {
$message = $lng->txt("update_error");
}
}
// If we are successful, we destroy the password assistance
// session and redirect to the login page.
// Else we display the form again along with an error message.
// ------------------
if ($is_successful) {
db_pwassist_session_destroy($pwassist_id);
$this->showMessageForm(null, sprintf($lng->txt("pwassist_password_assigned"), $username));
} else {
$this->showAssignPasswordForm($message, $username, $password1, $password2, $pwassist_id);
}
}
}