diff --git a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
index 9bc32b7..6b0520c 100644
--- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
+++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
@@ -49,17 +49,22 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1'] = array(
'#type' => 'password',
- '#title' => t('Password'),
+ '#title' => !empty($element['#title1']) ? $element['#title1'] : t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
'#required' => $element['#required'],
'#attributes' => array('class' => array('password-field')),
);
$element['pass2'] = array(
'#type' => 'password',
- '#title' => t('Confirm password'),
+ '#title' => !empty($element['#title2']) ? $element['#title2'] : t('Confirm password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
'#required' => $element['#required'],
'#attributes' => array('class' => array('password-confirm')),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="pass[pass1]"]' => array('filled' => TRUE),
+ ),
+ ),
);
$element['#element_validate'] = array(array(get_called_class(), 'validatePasswordConfirm'));
$element['#tree'] = TRUE;
diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index d67cdef..13a0269 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -147,7 +147,6 @@ public function generate($name, $parameters = array(), $absolute = FALSE) {
* {@inheritdoc}
*/
public function generateFromRoute($name, $parameters = array(), $options = array()) {
- $options += array('prefix' => '');
$route = $this->getRoute($name);
$this->processRoute($name, $route, $parameters);
@@ -159,12 +158,6 @@ public function generateFromRoute($name, $parameters = array(), $options = array
$path = $this->getInternalPathFromRoute($route, $parameters);
$path = $this->processPath($path, $options);
- if (!empty($options['prefix'])) {
- $path = ltrim($path, '/');
- $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
- $path = '/' . str_replace('%2F', '/', rawurlencode($prefix)) . $path;
- }
-
$fragment = '';
if (isset($options['fragment'])) {
if (($fragment = trim($options['fragment'])) != '') {
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
index 9b9bc4f..da96c8a 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
@@ -134,8 +134,6 @@ public function getPathFromRoute($name, $parameters = array());
* respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
* - 'base_url': Only used internally by a path processor, for example, to
* modify the base URL when a language dependent URL requires so.
- * - 'prefix': Only used internally, to modify the path when a language
- * dependent URL requires so.
*
* @return string
* The generated URL for the given route.
diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
index b76b1b1..58f6baa 100644
--- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
+++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php
@@ -142,7 +142,7 @@ public function processOutbound($path, &$options = array(), Request $request = N
$config = $this->config->get('language.negotiation')->get('url');
if ($config['source'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->getId()])) {
- $options['prefix'] = $config['prefixes'][$options['language']->getId()] . '/';
+ return empty($path) ? $config['prefixes'][$options['language']->id] : $config['prefixes'][$options['language']->id] . '/' . $path;
}
}
elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) {
diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
index 32a8649..4109f4a 100644
--- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
@@ -42,10 +42,6 @@ protected function setUp() {
// Enable URL language detection and selection.
$edit = array('language_interface[enabled][language-url]' => 1);
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
-
- // Check that drupalSettings contains path prefix.
- $this->drupalGet('fr/admin/config/regional/language/detection');
- $this->assertRaw('"pathPrefix":"fr\/"', 'drupalSettings path prefix contains language code.');
}
/**
diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php
index a322b09..2bc5c8e 100644
--- a/core/modules/user/src/AccountForm.php
+++ b/core/modules/user/src/AccountForm.php
@@ -118,8 +118,10 @@ public function form(array $form, FormStateInterface $form_state) {
if (!$register) {
$form['account']['pass'] = array(
'#type' => 'password_confirm',
+ '#prefix' => '
' . $this->t('Change password') . '
',
+ '#title2' => $this->t('New password confirmation'),
'#size' => 25,
- '#description' => $this->t('To change the current user password, enter the new password in both fields.'),
+ '#description' => $this->t('To change the current user password enter the new password.'),
);
// To skip the current password field, the user must have logged in via a
@@ -133,9 +135,9 @@ public function form(array $form, FormStateInterface $form_state) {
// password if they logged in via a one-time login link.
if (!$pass_reset) {
$protected_values['mail'] = $form['account']['mail']['#title'];
- $protected_values['pass'] = $this->t('Password');
+ $protected_values['pass'] = $this->t('New password');
$request_new = $this->l($this->t('Request new password'), new Url('user.pass', array(), array('attributes' => array('title' => $this->t('Request new password via email.')))));
- $current_pass_description = $this->t('Required if you want to change the %mail or %pass below. !request_new.', array('%mail' => $protected_values['mail'], '%pass' => $protected_values['pass'], '!request_new' => $request_new));
+ $current_pass_description = $this->t('Confirm your current password to change the %mail or %pass above. !request_new.', array('%mail' => $protected_values['mail'], '%pass' => $protected_values['pass'], '!request_new' => $request_new));
}
// The user must enter their current password to change to a new one.
@@ -151,11 +153,17 @@ public function form(array $form, FormStateInterface $form_state) {
'#size' => 25,
'#access' => !empty($protected_values),
'#description' => $current_pass_description,
- '#weight' => -5,
// Do not let web browsers remember this password, since we are
// trying to confirm that the person submitting the form actually
// knows the current one.
'#attributes' => array('autocomplete' => 'off'),
+ '#states' => array(
+ // Only show this field when mail or new password has changed.
+ 'visible' => array(
+ array(':input[name="mail"]' => array('!value' => $account->getEmail())),
+ array(':input[name="pass[pass1]"]' => array('filled' => TRUE)),
+ ),
+ ),
);
$form_state->set('user', $account);
diff --git a/core/modules/user/src/Tests/UserEditTest.php b/core/modules/user/src/Tests/UserEditTest.php
index 308fad9..7dca5b4 100644
--- a/core/modules/user/src/Tests/UserEditTest.php
+++ b/core/modules/user/src/Tests/UserEditTest.php
@@ -47,7 +47,7 @@ function testUserEdit() {
$edit = array();
$edit['mail'] = $this->randomMachineName() . '@new.example.com';
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
- $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Email address'))));
+ $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the \"%name\" field.", array('%name' => 'Email address')));
$edit['current_pass'] = $user1->pass_raw;
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
@@ -58,7 +58,7 @@ function testUserEdit() {
$edit['pass[pass1]'] = $new_pass = $this->randomMachineName();
$edit['pass[pass2]'] = $new_pass;
$this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
- $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Password'))));
+ $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the \"%name\" field.", array('%name' => 'New password')));
// Try again with the current password.
$edit['current_pass'] = $user1->pass_raw;
diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/src/Tests/UserPasswordResetTest.php
index b0f91be..a9ed5c4 100644
--- a/core/modules/user/src/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/src/Tests/UserPasswordResetTest.php
@@ -97,7 +97,7 @@ function testUserPasswordReset() {
// Verify that the password reset session has been destroyed.
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertText(t('Your current password is missing or incorrect; it\'s required to change the Password.'), 'Password needed to make profile changes.');
+ $this->assertText(t('Your current password is missing or incorrect; it\'s required to change the "New password" field.'), 'Password needed to make profile changes.');
// Log out, and try to log in again using the same one-time link.
$this->drupalLogout();
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index a251fd7..cfcbe90 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -398,6 +398,32 @@ function _user_role_permissions_update($roles) {
}
/**
+ * Determine whether the user has a given privilege.
+ *
+ * @param $string
+ * The permission, such as "administer nodes", being checked for.
+ * @param \Drupal\Core\Session\AccountInterface $account
+ * (optional) The account to check, if not given use currently logged in user.
+ *
+ * @return bool
+ * Boolean TRUE if the current user has the requested permission.
+ *
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal\Core\Session\AccountInterface::hasPermission().
+ */
+function user_access($string, AccountInterface $account = NULL) {
+ global $user;
+
+ if (!isset($account)) {
+ // In the installer request session is not set, so we have to fall back
+ // to the global $user. In all other cases the session key is preferred.
+ $account = \Drupal::currentUser() ?: $user;
+ }
+
+ return $account->hasPermission($string);
+}
+
+/**
* Checks for usernames blocked by user administration.
*
* @param $name
@@ -440,7 +466,7 @@ function user_validate_current_pass(&$form, FormStateInterface $form_state) {
if ((strlen(trim($form_state->getValue($key))) > 0) && ($form_state->getValue($key) != $current_value)) {
$current_pass_failed = $form_state->isValueEmpty('current_pass') || !\Drupal::service('password')->check($form_state->getValue('current_pass'), $account);
if ($current_pass_failed) {
- $form_state->setErrorByName('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
+ $form_state->setErrorByName('current_pass', t("Your current password is missing or incorrect; it's required to change the \"%name\" field.", array('%name' => $name)));
$form_state->setErrorByName($key);
}
// We only need to check the password once.
diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
index ffbfb03..48071ae 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php
@@ -203,7 +203,7 @@ public function routingTableDefinition() {
'default' => '',
),
'access_callback' => array(
- 'description' => 'The callback which determines the access to this router path. Defaults to \Drupal\Core\Session\AccountInterface::hasPermission.',
+ 'description' => 'The callback which determines the access to this router path. Defaults to user_access.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,