示例#1
0
def login():
    # service = request.args.get("service")
    # ticket = request.args.get("ticket")
    # print(service, ticket)
    # root = CASService.get_cas_respond(service, ticket)
    root = CASService.get_root()
    # print(root)
    username = root.find("cas:authenticationSuccess/cas:user",
                         Config.XML_NAMESPACES).text
    user_schema = UserSchema()
    user = user_schema.dump(UserController.find_user_by_username(username))
    #  print(user)
    response = {'data_response': user, 'status_code': 202}
    from flask import jsonify
    return jsonify(response), 202
示例#2
0
def create_item():
    data = request.get_json()
    if 'username' in data and 'user_full_name' in data and 'user_email' in data:
        existing_user = UserController.find_user_by_username(
            username=data['username']).first()
        if existing_user is not None:
            response = {'message': 'user already exists'}
            return jsonify(response), 403
        error = UserController.create_item(
            username=data['username'],
            user_full_name=data['user_full_name'],
            user_email=data['user_email'])
        if type(error) is str:
            response = {'status': 'error', 'message': error}
            return jsonify(response), 400
        response = {'message': "new user registered"}
        return jsonify(response), 202
    response = {'status': 'error', 'message': 'bad request body'}
    return jsonify(response), 400