From 8309e3deec9ed50ff35fae0bddfb9a409f1fb487 Mon Sep 17 00:00:00 2001
From: Daniel Speicher <daniel.speicher@lakedrops.com>
Date: Mon, 10 Jun 2024 09:13:45 +0200
Subject: [PATCH] Remove patch for module legal
 https://www.drupal.org/project/legal/issues/3074688

---
 patches/d10-3.json       |   3 --
 patches/d10.json         |   3 --
 patches/d10/3074688.diff | 104 ---------------------------------------
 patches/d9.json          |   3 +-
 4 files changed, 1 insertion(+), 112 deletions(-)
 delete mode 100644 patches/d10/3074688.diff

diff --git a/patches/d10-3.json b/patches/d10-3.json
index 5b002af..470124d 100644
--- a/patches/d10-3.json
+++ b/patches/d10-3.json
@@ -155,9 +155,6 @@
     "drupal/ldap": {
       "#3227813 Hide password field": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3227813.diff"
     },
-    "drupal/legal": {
-      "#3074688 Password reset links no longer work": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3074688.diff"
-    },
     "drupal/linkchecker": {
       "#3376854 Base path": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3376854.diff",
       "#3313343 Disable cron": "https://www.drupal.org/files/issues/2022-10-03/support_disabling_cron-3313343-2.patch"
diff --git a/patches/d10.json b/patches/d10.json
index 5a3f403..3f28e4e 100644
--- a/patches/d10.json
+++ b/patches/d10.json
@@ -157,9 +157,6 @@
     "drupal/ldap": {
       "#3227813 Hide password field": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3227813.diff"
     },
-    "drupal/legal": {
-      "#3074688 Password reset links no longer work": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3074688.diff"
-    },
     "drupal/linkchecker": {
       "#3376854 Base path": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3376854.diff",
       "#3313343 Disable cron": "https://www.drupal.org/files/issues/2022-10-03/support_disabling_cron-3313343-2.patch"
diff --git a/patches/d10/3074688.diff b/patches/d10/3074688.diff
deleted file mode 100644
index 4863277..0000000
--- a/patches/d10/3074688.diff
+++ /dev/null
@@ -1,104 +0,0 @@
-diff --git a/legal.module b/legal.module
-index 87e58d0101cae7f556f4bc3cc21ea7867aaf22b7..d5b16a142b60f519340b28483f78c39d3d3b6aca 100644
---- a/legal.module
-+++ b/legal.module
-@@ -489,12 +489,22 @@ function legal_user_login(UserInterface $account) {
- 
-   $query = NULL;
-   $path = \Drupal::request()->getpathInfo();
--  $arg = explode('/', $path);
-+  $checkPath = str_replace('dummy/dummy/login', '', Url::fromRoute('user.reset.login', [
-+    'uid' => $account->id(),
-+    'timestamp' => 'dummy',
-+    'hash' => 'dummy',
-+  ])->toString());
- 
-   // One time login link - set user edit page as destination after T&Cs.
--  if (isset($arg[1]) && $arg[1] == 'user' && isset($arg[2]) && $arg[2] == 'reset') {
-+  if (strpos($path, $checkPath) === 0) {
-+    $token = Crypt::randomBytesBase64(55);
-     $query = [
--      'destination' => $account->toUrl('edit-form')->toString(),
-+      'destination' => $account->toUrl('edit-form', [
-+          'query' => ['pass-reset-token' => $token],
-+          'absolute' => FALSE,
-+        ],
-+      )->toString(),
-+      'pass-reset-token' => $token,
-     ];
-   }
- 
-diff --git a/src/Form/LegalLogin.php b/src/Form/LegalLogin.php
-index 9f37ffcfa6de7f9c334ec872615f4a55a3c5a84a..8cbb7d5d582e5e9e4100adde086bc23fc62ebdee 100644
---- a/src/Form/LegalLogin.php
-+++ b/src/Form/LegalLogin.php
-@@ -194,6 +194,12 @@ class LegalLogin extends FormBase {
- 
-     if (!empty($_GET['destination'])) {
-       $redirect = $_GET['destination'];
-+      if (!empty($_GET['pass-reset-token'])) {
-+        // Store password reset token in session for \Drupal\user\AccountForm::form.
-+        \Drupal::request()->getSession()->set('pass_reset_' . $user->id(), $_GET['pass-reset-token']);
-+        // Clear any flood events for this user.
-+        \Drupal::service('flood')->clear('user.password_request_user', $user->id());
-+      }
-     }
- 
-     $form_state->setRedirectUrl(Url::fromUserInput($redirect));
-diff --git a/tests/src/Functional/PasswordResetTest.php b/tests/src/Functional/PasswordResetTest.php
-index 85afa9da30cce8b5d66efe7da672486b2fe6a87d..2d78cbf2c0c836df2d67c50b04aac2ad121984c3 100644
---- a/tests/src/Functional/PasswordResetTest.php
-+++ b/tests/src/Functional/PasswordResetTest.php
-@@ -17,6 +17,11 @@ class PasswordResetTest extends LegalTestBase {
-     getMails as drupalGetMails;
-   }
- 
-+  /**
-+   * {@inheritdoc}
-+   */
-+  protected $defaultTheme = 'stable';
-+
-   /**
-    * {@inheritdoc}
-    */
-@@ -25,7 +30,7 @@ class PasswordResetTest extends LegalTestBase {
- 
-     // Set the last login time that is used to generate the one-time link so
-     // that it is definitely over a second ago.
--    $this->account->login = \Drupal::time()->getRequestTime() - mt_rand(10, 100000);
-+    $this->account->login = \Drupal::time()->getRequestTime() - random_int(10, 100000);
-     \Drupal::database()->update('users_field_data')
-       ->fields(['login' => $this->account->getLastLoginTime()])
-       ->condition('uid', $this->account->id())
-@@ -35,6 +40,9 @@ class PasswordResetTest extends LegalTestBase {
- 
-   /**
-    * Test loging in with default Legal seetings.
-+   *
-+   * @throws \Drupal\Core\Entity\EntityMalformedException
-+   * @throws \Behat\Mink\Exception\ExpectationException
-    */
-   public function testPasswordReset() {
- 
-@@ -57,8 +65,7 @@ class PasswordResetTest extends LegalTestBase {
- 
-     // Check user is redirected to T&C acceptance page.
-     $expected_query = [
--      'destination' => $this->account->toUrl('edit-form')->toString(),
--      'token' => '',
-+      'destination' => $this->account->toUrl('edit-form', ['pass-reset-token' => ''])->toString(),
-     ];
-     $expected_url = Url::fromRoute('legal.legal_login', [], ['query' => $expected_query])->setAbsolute()->toString();
-     $this->assertStringStartsWith($expected_url, $this->getUrl());
-@@ -74,8 +81,9 @@ class PasswordResetTest extends LegalTestBase {
- 
-     // Check user is redirected to their user page.
-     $current_url = $this->getUrl();
--    $expected_url = $this->baseUrl . '/user/' . $this->uid . '/edit?check_logged_in=1';
--    $this->assertEquals($expected_url, $current_url);
-+    $expected_url = $this->baseUrl . '/user/' . $this->uid . '/edit?pass-reset-token=';
-+    $this->assertStringStartsWith($expected_url, $current_url);
-+    $this->assertStringEndsWith("&check_logged_in=1", $current_url);
-   }
- 
- }
diff --git a/patches/d9.json b/patches/d9.json
index 697dac5..990c795 100644
--- a/patches/d9.json
+++ b/patches/d9.json
@@ -169,8 +169,7 @@
       "#3227813 Hide password field": "https://git.drupalcode.org/project/ldap/-/merge_requests/21.diff"
     },
     "drupal/legal": {
-      "#3252838 Avoid session_destroy warnings": "https://git.drupalcode.org/project/legal/-/commit/add472c7e449a4fca3e40c7b9ed800c92ecc7cab.diff",
-      "#3074688 Password reset links no longer work": "https://git.drupalcode.org/project/legal/-/merge_requests/7.diff"
+      "#3252838 Avoid session_destroy warnings": "https://git.drupalcode.org/project/legal/-/commit/add472c7e449a4fca3e40c7b9ed800c92ecc7cab.diff"
     },
     "drupal/link_attributes": {
       "#3050455 Array ri string conversion": "https://www.drupal.org/files/issues/2019-04-24/3050455-2.link_attributes.Array-to-string-conversion-in-DrupalCoreTemplateAttributeArraytoString.patch"
-- 
GitLab