From 36bbcb180ca79bc1153ef229da4120a71d1a9951 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander.schlemmer@ds.mpg.de>
Date: Tue, 24 Nov 2020 13:34:38 +0100
Subject: [PATCH] ENH: convenience function for getting the username from a
 connection object

---
 src/caosdb/connection/connection.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/caosdb/connection/connection.py b/src/caosdb/connection/connection.py
index 65c8413c..86fa309e 100644
--- a/src/caosdb/connection/connection.py
+++ b/src/caosdb/connection/connection.py
@@ -608,3 +608,12 @@ class _Connection(object):  # pylint: disable=useless-object-inheritance
         _handle_response_status(http_response)
 
         return http_response
+
+    def get_username(self):
+        """
+        Return the username of the current connection.
+        
+        Shortcut for: get_connection()._authenticator._credentials_provider.username
+        """
+        return self._authenticator._credentials_provider.username
+
-- 
GitLab