本文整理汇总了PHP中eZUser::validatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::validatePassword方法的具体用法?PHP eZUser::validatePassword怎么用?PHP eZUser::validatePassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::validatePassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPostData
function processPostData()
{
$user = array();
$user['first_name'] = $this->Http->postVariable( 'eZSetup_site_templates_first_name' );
$user['last_name'] = $this->Http->postVariable( 'eZSetup_site_templates_last_name' );
$user['email'] = $this->Http->postVariable( 'eZSetup_site_templates_email' );
if ( strlen( trim( $user['first_name'] ) ) == 0 )
{
$this->Error[] = self::FIRST_NAME_MISSING;
}
if ( strlen( trim( $user['last_name'] ) ) == 0 )
{
$this->Error[] = self::LAST_NAME_MISSING;
}
if ( strlen( trim( $user['email'] ) ) == 0 )
{
$this->Error[] = self::EMAIL_MISSING;
}
else if ( !eZMail::validate( trim( $user['email'] ) ) )
{
$this->Error[] = self::EMAIL_INVALID;
}
if ( strlen( trim( $this->Http->postVariable( 'eZSetup_site_templates_password1' ) ) ) == 0 )
{
$this->Error[] = self::PASSWORD_MISSING;
}
else if ( $this->Http->postVariable( 'eZSetup_site_templates_password1' ) != $this->Http->postVariable( 'eZSetup_site_templates_password2' ) )
{
$this->Error[] = self::PASSWORD_MISSMATCH;
}
else if ( !eZUser::validatePassword( trim( $this->Http->postVariable( 'eZSetup_site_templates_password1' ) ) ) )
{
$this->Error[] = self::PASSWORD_TOO_SHORT;
}
else
{
$user['password'] = $this->Http->postVariable( 'eZSetup_site_templates_password1' );
}
if ( !isset( $user['password'] ) )
$user['password'] = '';
$this->PersistenceList['admin'] = $user;
return ( count( $this->Error ) == 0 );
}
示例2: setInformation
function setInformation($id, $login, $email, $password, $passwordConfirm = false)
{
$this->setAttribute("contentobject_id", $id);
$this->setAttribute("email", $email);
$this->setAttribute("login", $login);
if (eZUser::validatePassword($password) and $password == $passwordConfirm) {
$this->setAttribute("password_hash", eZUser::createHash($login, $password, eZUser::site(), eZUser::hashType()));
$this->setAttribute("password_hash_type", eZUser::hashType());
} else {
$this->setOriginalPassword($password);
$this->setOriginalPasswordConfirm($passwordConfirm);
}
}
示例3: validateUserInput
/**
* Validates input from user registration form
*
* @param eZHTTPTool $http
*
* @return array
*/
public static function validateUserInput($http)
{
if ($http->hasPostVariable('data_user_login') && $http->hasPostVariable('data_user_email') && $http->hasPostVariable('data_user_password') && $http->hasPostVariable('data_user_password_confirm')) {
$loginName = $http->postVariable('data_user_login');
$email = $http->postVariable('data_user_email');
$password = $http->postVariable('data_user_password');
$passwordConfirm = $http->postVariable('data_user_password_confirm');
if (trim($loginName) == '') {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The username must be specified.'));
} else {
$existUser = eZUser::fetchByName($loginName);
if ($existUser != null) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The username already exists, please choose another one.'));
}
// validate user email
$isValidate = eZMail::validate($email);
if (!$isValidate) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The email address is not valid.'));
}
$authenticationMatch = eZUser::authenticationMatch();
if ($authenticationMatch & eZUser::AUTHENTICATE_EMAIL) {
if (eZUser::requireUniqueEmail()) {
$userByEmail = eZUser::fetchByEmail($email);
if ($userByEmail != null) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'A user with this email already exists.'));
}
}
}
// validate user name
if (!eZUser::validateLoginName($loginName, $errorText)) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', $errorText));
}
// validate user password
$ini = eZINI::instance();
$generatePasswordIfEmpty = $ini->variable("UserSettings", "GeneratePasswordIfEmpty") == 'true';
if (!$generatePasswordIfEmpty || $password != "") {
if ($password == "") {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password cannot be empty.', 'eZUserType'));
}
if ($password != $passwordConfirm) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The passwords do not match.', 'eZUserType'));
}
if (!eZUser::validatePassword($password)) {
$minPasswordLength = $ini->hasVariable('UserSettings', 'MinPasswordLength') ? $ini->variable('UserSettings', 'MinPasswordLength') : 3;
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password must be at least %1 characters long.', null, array($minPasswordLength)));
}
if (strtolower($password) == 'password') {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password must not be "password".'));
}
}
}
} else {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
}
return array('status' => 'success');
}
示例4: validateObjectAttributeHTTPInput
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
if ($http->hasPostVariable($base . "_data_user_login_" . $contentObjectAttribute->attribute("id")) && $http->hasPostVariable($base . "_data_user_email_" . $contentObjectAttribute->attribute("id")) && $http->hasPostVariable($base . "_data_user_password_" . $contentObjectAttribute->attribute("id")) && $http->hasPostVariable($base . "_data_user_password_confirm_" . $contentObjectAttribute->attribute("id"))) {
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$loginName = $http->postVariable($base . "_data_user_login_" . $contentObjectAttribute->attribute("id"));
$email = $http->postVariable($base . "_data_user_email_" . $contentObjectAttribute->attribute("id"));
$password = $http->postVariable($base . "_data_user_password_" . $contentObjectAttribute->attribute("id"));
$passwordConfirm = $http->postVariable($base . "_data_user_password_confirm_" . $contentObjectAttribute->attribute("id"));
if (trim($loginName) == '') {
if ($contentObjectAttribute->validateIsRequired() || trim($email) != '') {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The username must be specified.'));
return eZInputValidator::STATE_INVALID;
}
} else {
$existUser = eZUser::fetchByName($loginName);
if ($existUser != null) {
$userID = $existUser->attribute('contentobject_id');
if ($userID != $contentObjectAttribute->attribute("contentobject_id")) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The username already exists, please choose another one.'));
return eZInputValidator::STATE_INVALID;
}
}
// validate user email
$isValidate = eZMail::validate($email);
if (!$isValidate) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The email address is not valid.'));
return eZInputValidator::STATE_INVALID;
}
$authenticationMatch = eZUser::authenticationMatch();
if ($authenticationMatch & eZUser::AUTHENTICATE_EMAIL) {
if (eZUser::requireUniqueEmail()) {
$userByEmail = eZUser::fetchByEmail($email);
if ($userByEmail != null) {
$userID = $userByEmail->attribute('contentobject_id');
if ($userID != $contentObjectAttribute->attribute("contentobject_id")) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A user with this email already exists.'));
return eZInputValidator::STATE_INVALID;
}
}
}
}
// validate user name
if (!eZUser::validateLoginName($loginName, $errorText)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', $errorText));
return eZInputValidator::STATE_INVALID;
}
// validate user password
$ini = eZINI::instance();
$generatePasswordIfEmpty = $ini->variable("UserSettings", "GeneratePasswordIfEmpty") == 'true';
if (!$generatePasswordIfEmpty || $password != "") {
if ($password == "") {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The password cannot be empty.', 'eZUserType'));
return eZInputValidator::STATE_INVALID;
}
if ($password != $passwordConfirm) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The passwords do not match.', 'eZUserType'));
return eZInputValidator::STATE_INVALID;
}
if (!eZUser::validatePassword($password)) {
$minPasswordLength = $ini->variable('UserSettings', 'MinPasswordLength');
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The password must be at least %1 characters long.', null, array($minPasswordLength)));
return eZInputValidator::STATE_INVALID;
}
if (strtolower($password) == 'password') {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The password must not be "password".'));
return eZInputValidator::STATE_INVALID;
}
}
// validate confirm email
if ($ini->variable('UserSettings', 'RequireConfirmEmail') == 'true') {
$emailConfirm = $http->postVariable($base . "_data_user_email_confirm_" . $contentObjectAttribute->attribute("id"));
if ($email != $emailConfirm) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The emails do not match.', 'eZUserType'));
return eZInputValidator::STATE_INVALID;
}
}
}
} else {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
}