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)
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 })
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)
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, } )
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 } })
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'})
def basic_auth_error(): """Simply returns a unauthorized HTTP error.""" return unauthorized()
def auth_error(): return unauthorized('Invalid credentials')
def unauthorized_handler(e): return unauthorized('Unauthorized')
def token_auth_error(): return unauthorized()
def basic_auth_error(): return unauthorized()
def before_request(): if g.current_user.is_anonymous: return unauthorized('Invalid credentials') if not g.current_user.confirmed: return unauthorized('Invalid credentials')
def auth_error() -> Response: return unauthorized("Invalid credentials")
def auth_error(): return unauthorized("无效的证书")
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})