Пример #1
0
 def forbidden(**kw):
     raise ProcessingException(status=403, detail='forbidden')
Пример #2
0
 def raise_error(**kw):
     raise ProcessingException(status=500)
Пример #3
0
def handle400():
    return ProcessingException(description=STATUS_MESSAGE.BAD_REQUEST,
                               code=STATUS_CODE.ER_400)
Пример #4
0
def handle405():
    return ProcessingException(description=STATUS_MESSAGE['METHOD_NOT_ALLOWED'], code=STATUS_CODE['ER_405'])
Пример #5
0
def handle401():
    return ProcessingException(description=STATUS_MESSAGE.NOT_AUTHORIZED,
                               code=STATUS_CODE.ER_401)
Пример #6
0
def handle405():
    return ProcessingException(description=STATUS_MESSAGE.METHOD_NOT_ALLOWED,
                               code=STATUS_CODE.ER_405)
Пример #7
0
def auth_admin_func(instance_id=None, **kwargs):
    current_user = get_jwt_identity()
    if not current_user == "jim":

        raise ProcessingException(description='Only admins can access this view', code=401)
Пример #8
0
def preprocessors_check_adm_or_normal_user(instance_id=None, **kargs):
    if not (current_user.is_admin or current_user.username == instance_id):
        raise ProcessingException(description='Forbidden', code=403)
Пример #9
0
def is_auth_to_app_edit(*args, **kw):
     if not current_user.group.app_edit_all:
        raise ProcessingException(description='Not authenticated!', code=401)
Пример #10
0
def is_auth_to_user_drop(*args, **kw):
    if not current_user.group.user_drop:
        raise ProcessingException(description='Not authenticated!', code=401)
Пример #11
0
def auth_func(*args, **kw):
    if not login_fresh() and not current_user.is_authenticated:
        if not 'user' in session:
            raise ProcessingException(description='Not authenticated!', code=401)
Пример #12
0
def handle401():
    return ProcessingException(description=STATUS_MESSAGE['NOT_AUTHORIZED'], code=STATUS_CODE['ER_401'])
Пример #13
0
def handle400():
    return ProcessingException(description=STATUS_MESSAGE['BAD_REQUEST'], code=STATUS_CODE['ER_400'])
Пример #14
0
def auth(*args, **kargs):
    """
    Required API request to be authenticated
    """
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated', code=401)
Пример #15
0
def auth_func(**kw):
    '''Ensures api users are authenticated.'''
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not Authorized', code=401)
Пример #16
0
def preprocessor_check_adm(*args, **kargs):
    if not current_user.is_admin:
        raise ProcessingException(description='Forbidden', code=403)
Пример #17
0
def auth_func(**kw):
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not Authorized', code=401)
Пример #18
0
 def is_authorized(self, user, obj):
     if user.id != obj.user_id:
         raise ProcessingException(description='Not Authorized', code=401)
Пример #19
0
def auth_request(**kw):
    if not current_user.is_authenticated:
        user = load_user_from_request(request)
        if not user:
            raise ProcessingException(description='Not Authorized', status=401)
Пример #20
0
def handle404():
    return ProcessingException(description=STATUS_MESSAGE.NOT_FOUND,
                               code=STATUS_CODE.ER_404)
Пример #21
0
    def check(description, amount, content):

        if (not description) or (not amount) or (not content):
            raise ProcessingException(description='Tositteista puuttuu tietoja.')
Пример #22
0
def handle500():
    return ProcessingException(
        description=STATUS_MESSAGE.INTERNAL_SERVER_ERROR,
        code=STATUS_CODE.ER_500)
Пример #23
0
def authenticate(*args, **kwargs):
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated', code=401)
Пример #24
0
 def delete_preprocessor(self, instance_id=None, **kw):
     try:
         article = ArticleController(current_user.id).get(id=instance_id)
     except NotFound:
         raise ProcessingException(description='No such article.', code=404)
     self.is_authorized(current_user, article)
Пример #25
0
def handle404():
    return ProcessingException(description=STATUS_MESSAGE['NOT_FOUND'], code=STATUS_CODE['ER_404'])