def get_auth_token(self): """ Return an authentication token for the user. The auth token uniquely identifies the user and includes the salted hash of the password, then encrypted with a Timed serializer. The token_validity_duration can be set in application configuration using TOKEN_VALIDITY_DURATION """ serializer = TimedJSONWebSignatureSerializer( current_app.secret_key, expires_in=current_app.token_validity_duration) local_txn = None if Transaction().connection is None: # Flask-Login can call get_auth_token outside the context # of a nereid transaction. If that is the case, launch a # new transaction here. local_txn = Transaction().start(current_app.database_name, 0, readonly=True) self = self.__class__(self.id) try: return serializer.dumps({'id': self.id, 'password': self.password}) finally: if local_txn is not None: # TODO: Find a better way to close transaction local_txn.__exit__(None, None, None)
def get_auth_token(self): """ Return an authentication token for the user. The auth token uniquely identifies the user and includes the salted hash of the password, then encrypted with a Timed serializer. The token_validity_duration can be set in application configuration using TOKEN_VALIDITY_DURATION """ serializer = TimedJSONWebSignatureSerializer( current_app.secret_key, expires_in=current_app.token_validity_duration ) local_txn = None if Transaction().connection is None: # Flask-Login can call get_auth_token outside the context # of a nereid transaction. If that is the case, launch a # new transaction here. local_txn = Transaction().start(current_app.database_name, 0, readonly=True) self = self.__class__(self.id) try: return serializer.dumps({"id": self.id, "password": self.password}) finally: if local_txn is not None: # TODO: Find a better way to close transaction local_txn.__exit__(None, None, None)
def decorated_function(self, *args, **kwargs): transaction = None if Transaction().connection is None: # Start transaction since connection is None transaction = Transaction().start( self.database_name, 0, readonly=True ) try: return function(self, *args, **kwargs) finally: if transaction is not None: # TODO: Find some better way close transaction transaction.__exit__(None, None, None)
def decorated_function(self, *args, **kwargs): transaction = None if Transaction().connection is None: # Start transaction since connection is None transaction = Transaction().start(self.database_name, 0, readonly=True) try: return function(self, *args, **kwargs) finally: if transaction is not None: # TODO: Find some better way close transaction transaction.__exit__(None, None, None)