def whoAmI(): '''Return the currently logged-in user identity. Parameters ---------- None Returns ------- name : str Currently logged-in user name, or 'anonymous' if not logged-in Example ------- .. code-block:: python from dl import authClient name = authClient.whoAmI() ''' user = '******' try: token = def_token(None) user, uid, gid, hash = token.strip().split('.', 3) except: return 'anonymous' else: return user
def whoAmI(): user = '******' try: token = def_token(None) user, uid, gid, hash = token.strip().split('.', 3) except: return 'anonymous' else: return user
def getHeaders(self, token): '''Get default tracking headers. ''' tok = def_token(token) user, uid, gid, hash = tok.strip().split('.', 3) hdrs = { 'Content-Type': 'text/ascii', 'X-DL-ClientVersion': __version__, 'X-DL-OriginIP': self.hostip, 'X-DL-OriginHost': self.hostname, 'X-DL-User': user, 'X-DL-AuthToken': tok } # application/x-sql return hdrs
def logout(token=None): try: response = ac_client.logout(def_token(token)) except Exception as e: response = str(e) return response