This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new d7c9f5899a7 Fix login redirect loop if user has multiple cookies 
(#47913)
d7c9f5899a7 is described below

commit d7c9f5899a7340c14d17c0ea7ce5ea50710fdea2
Author: Brent Bovenzi <[email protected]>
AuthorDate: Tue Mar 18 11:35:31 2025 -0400

    Fix login redirect loop if user has multiple cookies (#47913)
    
    * Fix login redirect loop if user has multiple cookies
    
    * use .trim() instead of .includes()
---
 airflow/ui/src/utils/tokenHandler.ts | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/airflow/ui/src/utils/tokenHandler.ts 
b/airflow/ui/src/utils/tokenHandler.ts
index 4939585c8ef..912ee374a03 100644
--- a/airflow/ui/src/utils/tokenHandler.ts
+++ b/airflow/ui/src/utils/tokenHandler.ts
@@ -23,15 +23,13 @@ const getTokenFromCookies = (): string | undefined => {
   const cookies = document.cookie.split(";");
 
   for (const cookie of cookies) {
-    if (cookie.startsWith("_token=")) {
-      const [, token] = cookie.split("=");
+    const [name, token] = cookie.split("=");
 
-      if (token !== undefined) {
-        localStorage.setItem(TOKEN_STORAGE_KEY, token);
-        document.cookie = "_token=; expires=Thu, 01 Jan 2000 00:00:00 UTC; 
path=/;";
+    if (name?.trim() === "_token" && token !== undefined) {
+      localStorage.setItem(TOKEN_STORAGE_KEY, token);
+      document.cookie = "_token=; expires=Thu, 01 Jan 2000 00:00:00 UTC; 
path=/;";
 
-        return token;
-      }
+      return token;
     }
   }
 

Reply via email to