Exemplo n.º 1
0
    def decorator(*args, **kwargs):

        token = None

        if 'Authorization' in request.headers:
            header_value = request.headers['Authorization']
            if header_value.find(' ') != -1:
                array = header_value.split(' ')
                if array[0] == 'token':
                    token = array[1]

        if not token:
            return jsonify({'message': 'Missing token', 'code': 12}), 403

        user_repo = UserRepository(MySQLFactory.get())
        current_user = user_repo.get_active_by_token(token)
        if None is current_user:
            return jsonify({'message': 'Token is invalid', 'code': 13}), 403

        # This method is the only one to need the current_user
        if 'renew_token' == decorated_function.__name__:
            return decorated_function(current_user, *args, **kwargs)

        return decorated_function(*args, **kwargs)
Exemplo n.º 2
0
def get_user():
    """Returns the user according to one filter"""
    controller = UserController
    return controller.get_by_filter(MySQLFactory.get(),
                                    request.args.get('filter', ''),
                                    request.args.get('value', ''))
Exemplo n.º 3
0
def get_transactions():
    """Get the transactions"""
    controller = TransactionController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 4
0
def create_transaction():
    """Create a transaction"""
    controller = TransactionController
    return controller.create(MySQLFactory.get())
Exemplo n.º 5
0
def get_stories():
    """Get the stories"""
    controller = StoryController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 6
0
def create_story():
    """Create a story"""
    controller = StoryController
    return controller.create(MySQLFactory.get())
Exemplo n.º 7
0
def get_copies():
    """Get the copies"""
    controller = CopyController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 8
0
def create_copy():
    """Create a copy"""
    controller = CopyController
    return controller.create(MySQLFactory.get())
Exemplo n.º 9
0
def get_platforms():
    """Get the platforms"""
    controller = PlatformController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 10
0
def delete_platform(entity_id):
    """Delete the platform according to its id"""
    controller = PlatformController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 11
0
def create_platform():
    """Create a platform"""
    controller = PlatformController
    return controller.create(MySQLFactory.get())
Exemplo n.º 12
0
def get_platform_by_id(entity_id):
    """Returns the platform according to its id"""
    controller = PlatformController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 13
0
def renew_token(current_user):
    """Renew the API token of the current user"""
    controller = UserController
    return controller.renew_token(MySQLFactory.get(), current_user)
Exemplo n.º 14
0
def update_user(entity_id):
    """Updates a user"""
    controller = UserController
    return controller.update(MySQLFactory.get(), entity_id)
Exemplo n.º 15
0
def create_user():
    """Creates a user"""
    controller = UserController
    return controller.create(MySQLFactory.get())
Exemplo n.º 16
0
def get_versions():
    """Get the versions"""
    controller = VersionController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 17
0
def get_copy_by_id(entity_id):
    """Returns the copy according to its id"""
    controller = CopyController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 18
0
def get_game_by_id(entity_id):
    """Returns the game according to its id"""
    controller = GameController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 19
0
def delete_copy(entity_id):
    """Delete the copy according to its id"""
    controller = CopyController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 20
0
def create_game():
    """Create a game"""
    controller = GameController
    return controller.create(MySQLFactory.get())
Exemplo n.º 21
0
def get_story_by_id(entity_id):
    """Returns the story according to its id"""
    controller = StoryController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 22
0
def delete_game(entity_id):
    """Delete the game according to its id"""
    controller = GameController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 23
0
def delete_story(entity_id):
    """Delete the story according to its id"""
    controller = StoryController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 24
0
def get_games():
    """Get the games"""
    controller = GameController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 25
0
def get_transaction_by_id(entity_id):
    """Returns the transaction according to its id"""
    controller = TransactionController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 26
0
def get_version_by_id(entity_id):
    """Returns the version according to its id"""
    controller = VersionController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 27
0
def delete_transaction(entity_id):
    """Delete the transaction according to its id"""
    controller = TransactionController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 28
0
def create_version():
    """Create a version"""
    controller = VersionController
    return controller.create(MySQLFactory.get())
Exemplo n.º 29
0
def delete_version(entity_id):
    """Delete the version according to its id"""
    controller = VersionController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 30
0
def authenticate_user():
    """Returns the token of the given user"""
    controller = UserController
    return controller.authenticate(MySQLFactory.get())