Commit 39671958 authored by alexpott's avatar alexpott

Issue #2393577 by, Berdir: Access issue with default settings set to disabled

parent 508aa670
......@@ -83,11 +83,13 @@ public function access(UserInterface $user, AccountInterface $account) {
return $access;
// If the requested user has disabled their contact form, do not allow users
// to contact them.
// Load preference of the requested user.
$account_data = $this->userData->get('contact', $contact_account->id(), 'enabled');
if (isset($account_data) && empty($account_data)) {
return $access;
if (isset($account_data)) {
// Forbid access if the requested user has disabled their contact form.
if (empty($account_data)) {
return $access;
// If the requested user did not save a preference yet, deny access if the
// configured default is disabled.
......@@ -185,6 +185,15 @@ function testPersonalContactAccess() {
$this->drupalPostForm(NULL, array('contact' => TRUE), t('Save'));
$this->assertTrue(\Drupal::service('')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled');
// Test with disabled global default contact form in combination with a user
// that has the contact form enabled.
\Drupal::config('contact.settings')->set('user_default_enabled', FALSE)->save();
$this->contactUser = $this->drupalCreateUser();
\Drupal::service('')->set('contact', $this->contactUser->id(), 'enabled', 1);
$this->drupalGet('user/' . $this->contactUser->id() . '/contact');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment