Handle devicename in login
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 30 Nov 2025 20:51:13 +0000 (21:51 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 30 Nov 2025 20:51:13 +0000 (21:51 +0100)
music_assistant/controllers/webserver/auth.py

index 186024b0a8802d5c228d61abea10170994f13e5e..f43f1014659dda122852a58609e4bf8435d11cbf 100644 (file)
@@ -915,6 +915,7 @@ class AuthenticationManager:
         username: str | None = None,
         password: str | None = None,
         provider_id: str = "builtin",
+        device_name: str | None = None,
         **extra_credentials: Any,
     ) -> dict[str, Any]:
         """Authenticate user with credentials via WebSocket.
@@ -925,6 +926,7 @@ class AuthenticationManager:
         :param username: Username for authentication (for builtin provider).
         :param password: Password for authentication (for builtin provider).
         :param provider_id: The login provider ID (defaults to "builtin").
+        :param device_name: Optional device name for the token (e.g., "iPhone 15", "Desktop PC").
         :param extra_credentials: Additional provider-specific credentials.
         :return: Authentication result with access token if successful.
         """
@@ -950,11 +952,12 @@ class AuthenticationManager:
                 "error": "Authentication failed: no user returned",
             }
 
-        # Create short-lived access token
+        # Create short-lived access token with device name if provided
+        token_name = device_name or f"WebSocket Session - {auth_result.user.username}"
         token = await self.create_token(
             auth_result.user,
             is_long_lived=False,
-            name=f"WebSocket Session - {auth_result.user.username}",
+            name=token_name,
         )
 
         return {