diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php
index 5d41275..a70ca18 100644
--- a/core/modules/user/src/RegisterForm.php
+++ b/core/modules/user/src/RegisterForm.php
@@ -88,8 +88,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// If we are not an admin and we try to register and password_register
// is set, make sure the status is set to disabled before we save
// the newly created account.
- if ($config->get('verify_mail') && $config->get('password_register') && $form_state->getValue('uid') && !$admin) {
- $form_state->setValue('status', NULL);
+ if ($config->get('verify_mail') && $config->get('password_register') && !$form_state->getValue('uid') && !$admin) {
+ $form_state->setValue('status', 0);
}
// Remove unneeded values.
@@ -105,6 +105,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
+ $config = \Drupal::config('user.settings');
$account = $this->entity;
$pass = $account->getPassword();
$admin = $form_state->getValue('administer_users');
@@ -127,15 +128,15 @@ public function save(array $form, FormStateInterface $form_state) {
drupal_set_message($this->t('Created a new user account for %name. No email has been sent.', array(':url' => $account->url(), '%name' => $account->getUsername())));
}
// E-mail verification enabled, but users set a password during registration.
- elseif (!$admin && (\Drupal::config('user.settings')->get('register') == USER_REGISTER_VISITORS && \Drupal::config('user.settings')->get('password_register') && !$account->status)) {
+ elseif (!$admin && $config->get('register') == USER_REGISTER_VISITORS && $config->get('password_register') && !$account->isActive()) {
// Notify the user.
_user_mail_notify('register_password_set', $account);
- drupal_set_message($this->t('A welcome message with further instructions has been sent to your e-mail address.'));
- $form_state->setRedirect('');
+ drupal_set_message($this->t('A welcome message with further instructions has been sent to your email address.'));
+ $form_state->setRedirect('');
}
// No email verification required; log in user immediately.
- elseif (!$admin && !\Drupal::config('user.settings')->get('verify_mail') && $account->isActive()) {
+ elseif (!$admin && !$config->get('verify_mail') && $account->isActive()) {
_user_mail_notify('register_no_approval_required', $account);
user_login_finalize($account);
drupal_set_message($this->t('Registration successful. You are now logged in.'));
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index 4698d92..dd2a7f1 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -145,11 +145,11 @@ function testRegistrationWithPasswordSet() {
// Create a new user.
$this->drupalPostForm('user/register', $edit, t('Create new account'));
- $this->assertText(t('A welcome message with further instructions has been sent to your e-mail address.'), 'Send e-mail to user after registering.');
+ $this->assertText(t('A welcome message with further instructions has been sent to your email address.'), 'Send e-mail to user after registering.');
// Make sure the user is still blocked.
- $this->container->get('entity.manager')->getStorageController('user')->resetCache();
- $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail, 'status' => 0));
+ $this->container->get('entity.manager')->getStorage('user')->resetCache();
+ $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail));
$new_user = reset($accounts);
$this->assertFalse($new_user->status->value, t('New account is blocked until approved via e-mail confirmation.'));
@@ -158,7 +158,7 @@ function testRegistrationWithPasswordSet() {
$edit2['name'] = $name;
$edit2['pass'] = $new_pass;
$this->drupalPostForm('user/login', $edit2, t('Log in'));
- $this->assertText(t('The username @name has not been activated or is blocked.', array('@name' => $name)), t('User cannot login yet.'));
+ $this->assertRaw(t('The username %name has not been activated or is blocked.', array('%name' => $name)), t('User cannot login yet.'));
// Try to activate the user.
$_emails = $this->drupalGetMails();