本文整理汇总了PHP中UserDAO::updateUserPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO::updateUserPassword方法的具体用法?PHP UserDAO::updateUserPassword怎么用?PHP UserDAO::updateUserPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDAO
的用法示例。
在下文中一共展示了UserDAO::updateUserPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forgotPasswordModel
public function forgotPasswordModel($forgotPasswordForm)
{
$formObjRaw = new FormDTO(FORGOT_PWD_FORM, $forgotPasswordForm);
$responseDTO = new ResponseDTO(FORGOT_PWD_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(FORGOT_PWD_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userDAO = new UserDAO();
$userDTO = $userDAO->getUserByEmail($formDataObj[FORGOT_PWD_FORM . EMAIL]);
if (is_null($userDTO)) {
$responseDTO->setErrField(ERROR_RESPONSE, "Nessun user presente con questa mail");
} else {
$newPassword = PasswordUtils::createRandomicPassword();
$userDTO->setPassword($newPassword);
$resultMail = DataModelUtils::sendMail($userDTO, FORGOT_PWD_FORM);
$hashedPwd = PasswordUtils::getPassword($newPassword);
$userDTO->setPassword($hashedPwd);
$result = $userDAO->updateUserPassword($userDTO);
if ($result != 1) {
$responseDTO->setErrField(ERROR_RESPONSE, "Problema nel cambio della password");
} else {
$responseDTO->setResponseSucc("Verra mandata una mail con una nuova password all'indirizzo " . $userDTO->getEmail());
}
}
} else {
if (array_key_exists(EMAIL, $validationError)) {
$responseDTO->setErrField(EMAIL, $validationError[EMAIL]);
}
SessionUtils::setFormValue($formDataObj);
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例2: changeUserPwdModel
function changeUserPwdModel($pwdForm)
{
$formObjRaw = new FormDTO(CHANGE_PWD_FORM, $pwdForm);
$responseDTO = new ResponseDTO(CHANGE_PWD_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(CHANGE_PWD_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userLogged = SessionUtils::getUserLogged();
$hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . PASSWORD]);
$userDTO = new UserDTO($userLogged->getUserId(), NULL, $hashedPwd, NULL, NULL, NULL, NULL, NULL);
$userDAO = new UserDAO();
$userLoggedDTO = $userDAO->checkPassword($userDTO);
if (is_null($userLoggedDTO)) {
$responseDTO->setResponseSucc("Questa password non esiste");
return $responseDTO;
}
$hashedPwd = PasswordUtils::getPassword($formDataObj[CHANGE_PWD_FORM . NEW_PASSWORD]);
$userDTO->setPassword($hashedPwd);
$userPwdUpdated = $userDAO->updateUserPassword($userDTO);
return $userDTO;
} else {
if (array_key_exists(PASSWORD, $validationError)) {
$responseDTO->setErrField(PASSWORD, $validationError[PASSWORD]);
}
if (array_key_exists(NEW_PASSWORD, $validationError)) {
$responseDTO->setErrField(NEW_PASSWORD, $validationError[NEW_PASSWORD]);
}
if (array_key_exists(CONFIRM_PASSWORD, $validationError)) {
$responseDTO->setErrField(CONFIRM_PASSWORD, $validationError[CONFIRM_PASSWORD]);
}
// var_dump($validationError);
// var_dump($responseDTO);die;
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}