Esempio n. 1
0
    def wrapped_view(**kwargs):
        if g.user is None:
            return unauthorized('token necessário')
        elif not g.user.admin:
            return unauthorized('admin necessário')

        return view(**kwargs)
Esempio n. 2
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({
        'token': g.current_user.generate_auth_token(expiration=3600),
        'expiration': 3600
    })
Esempio n. 3
0
def delete_holds():
    auth = request.args.get('auth', 'notme', type=str)
    if auth != 'me':
        return unauthorized('wrong auth')
    number_items = db.session.query(Hold).delete()
    db.session.commit()
    return jsonify(number_items)
Esempio n. 4
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized("无效的证书")

    return jsonify(
        {
            "token": g.current_user.generate_auth_token(expiration=3600),
            "expiration": 3600,
        }
    )
Esempio n. 5
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized('Invalid credentials')
    return jsonify({
        'status': 1,
        'body': {
            'token': g.current_user.generate_auth_token(expiration=3600),
            'expiration': 3600,
            'ip': 1 if g.current_user.is_administrator() else 0
        }
    })
Esempio n. 6
0
def move_todoitem():
    request_data = request.get_json()
    todo_list_id = int(request_data["todoListId"])
    todo_item_id = int(request_data["todoItemId"])
    todo_list = ToDoList.query.get_or_404(todo_list_id)
    user_or_email = auth.username()
    user = User.query.filter((User.email == user_or_email) | (
        User.username == user_or_email)).first()
    if todo_list.user != user:
        return unauthorized('You donot have access to this list')
    todo_item = ToDoItem.query.get_or_404(todo_item_id)
    todo_item.todo_list_id = todo_list.id
    db.session.add(todo_item)
    db.session.commit()
    return jsonify({'status':'success'})
Esempio n. 7
0
def basic_auth_error():
    """Simply returns a unauthorized HTTP error."""
    return unauthorized()
Esempio n. 8
0
def auth_error():
    return unauthorized('Invalid credentials')
Esempio n. 9
0
def unauthorized_handler(e):
    return unauthorized('Unauthorized')
Esempio n. 10
0
def token_auth_error():
    return unauthorized()
Esempio n. 11
0
def basic_auth_error():
    return unauthorized()
Esempio n. 12
0
def before_request():
    if g.current_user.is_anonymous:
        return unauthorized('Invalid credentials')
    if not g.current_user.confirmed:
        return unauthorized('Invalid credentials')
Esempio n. 13
0
def auth_error() -> Response:
    return unauthorized("Invalid credentials")
Esempio n. 14
0
def auth_error():
    return unauthorized("无效的证书")
Esempio n. 15
0
def get_token():
    if g.current_user.is_anonymous or g.token_used:
        return unauthorized("Invalid credentials")
    token = g.current_user.generate_auth_token(expiration=3600)
    return jsonify({"token": token, "expiration": 3600})